# 2 Buttons Equally Sized

**URL:** <https://forum.xojo.com/t/2-buttons-equally-sized/73806>\
**Category:** Targets\
**Created:** [December 23, 2022, 9:40pm UTC](https://forum.xojo.com/t/2-buttons-equally-sized/73806 "2022-12-23T21:40:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_Sittampalam](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/aca169/32.png) [@Alex\_Sittampalam](https://forum.xojo.com/u/Alex_Sittampalam)\
**Post date:** [December 23, 2022, 9:40pm UTC](https://forum.xojo.com/t/2-buttons-equally-sized/73806/1 "2022-12-23T21:40:43Z")

</div>

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.

 ![image](https://forum.xojo.com/uploads/default/original/2X/e/e239307099f80b0baa794b1f50ac11a38812cc3a.png)

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.

---

<div class="post-metadata">

**Author:** ![Tim\_Hare](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_hare/32/176_2.png) [@Tim\_Hare](https://forum.xojo.com/u/Tim_Hare)\
**Post date:** [December 23, 2022, 9:54pm UTC](https://forum.xojo.com/t/2-buttons-equally-sized/73806/2 "2022-12-23T21:54:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Alex\_Sittampalam](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/aca169/32.png) [@Alex\_Sittampalam](https://forum.xojo.com/u/Alex_Sittampalam)\
**Post date:** [December 24, 2022, 10:03am UTC](https://forum.xojo.com/t/2-buttons-equally-sized/73806/3 "2022-12-24T10:03:30Z")

</div>

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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![Alex\_Sittampalam](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/aca169/32.png) [@Alex\_Sittampalam](https://forum.xojo.com/u/Alex_Sittampalam)\
**Post date:** [December 24, 2022, 10:18am UTC](https://forum.xojo.com/t/2-buttons-equally-sized/73806/4 "2022-12-24T10:18:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Michel\_Bujardet](https://forum.xojo.com/user_avatar/forum.xojo.com/michel_bujardet/32/252_2.png) [@Michel\_Bujardet](https://forum.xojo.com/u/Michel_Bujardet)\
**Post date:** [December 24, 2022, 10:29am UTC](https://forum.xojo.com/t/2-buttons-equally-sized/73806/5 "2022-12-24T10:29:37Z")

</div>

Glad to read you got it.

I created a class that does exactly what you want.

Check it out at [rubberviews.com](http://rubberviews.com).
