2 Buttons Equally Sized

I would like to have 2 buttons which no matter what size a window is, will always be the same size as each other like in the picture.

Currently, when I resize the window, the buttons either overlap each other or leave a big gaping hole in the middle of them. I have tried changing the locks etc, but to no avail.

Locks don’t help with this. You have to calculate the size and positions yourself based on the window availableheight/width.

Thank you for your answer!

I have tried writing some code to do this, but it basically doesn’t even show the Edit button (it will appear for a bit while changing the size, then disappear again when I let go:

Var Width As Integer = Me.Width
Var ButtonWidth as Integer = (Width / 2) - 30
Var OffSet As Integer = Width + 10

NewProjectButton.Width = ButtonWidth

EditProjectButton.Width = ButtonWidth
EditProjectButton.Left = OffSet

This code is in the Resized handler of the window, and the buttons are in the controls section inside the window.

Aah, turns out I had used Width rather than Width / 2 to calculate the offset. It is now working perfectly!

Glad to read you got it.

I created a class that does exactly what you want.

Check it out at rubberviews.com.