Center a PushButton on a Window ?

This image below displays a bad example of a centered button (it was enlarged when I resized (up) the window.

How can I keep it centered, but with the same size ?

I forgot to tell the button name: New.

Hi,

You could use a ContainerControl. For instance, in the screenshot below, the first set of buttons are how you have it setup. The second set are in a container control (called buttonContainer) and then I have the following code in the Window’s Resized event.

ButtonContainer.left = (self.Width - ButtonContainer.Width)/2

Unlock the right side of New and put this in the Resizing window event :

pbNew.left = (self.width-pbNew.width)/2

You can do pretty much the same with other buttons, simply you need to set a window property with the ratio to use. For instance :

Sub Open() okratio = pbOK.left/self.width //okratio is a double window property End Sub

in the window resizing event :

pbOK.left = self.width*okratio

Thank you for both suggestions.

Before Xojo, there was a solution without code (nor container control), but as usual, I forgot it.