I have two listboxes displayed side by side.
If I lock the first one to all edges and the second one to all edges they overlap when the app is maximized
If I lock the first one to the top, left and bottom and the second one to all edges and maximize the app the second one expands but the first stays narrow.
How can I make it so that they both evenly expand in the window?
You will have to manipulate their widths during the resize event of their window manually, like calculate the horizontal mid and give the left one this value as width and the right one this value as x and width (or with a certain distance). Or use a plug-in or extension that gives you more sophisticated means of autoresizing/constraint-like layout features.
You may want to look at my RubberViews class at http://RubberViews.com
Thanks guys I will explore both options. I am doing this for a hobby project so I want to keep my cost at zero! I guess I will pull out the dusty calculator!
Here’s some example code from my current project that’s similar to what you want to do:
[code] // Spread descriptive labels across each half of view
w = (Self.ContentSize.Width - 40)/2 'Get width of view minus standard gaps divided by 2
width = New iOSLayoutConstraint(EncTextArea, _
width = New iOSLayoutConstraint(EncLabel, _
This code is in the Open event handler for the view.
Thanks Art. This is for an iOS app but the concept is the same. Thanks again!
@Art Gorski Thank you very much this helped greatly.
I adjusted the code you provided for my purpose and placed it in both the “Open” and “Resizing” Window Event Handlers.
'Calculated width for both listboxes
dim w As Integer
w = (Window1.Width - 40) / 2
Listbox1.Width = w
Listbox2.Width = w
'Left Position for Second Listbox
Listbox2.Left = w + 40
My example IS from an iOS project.
Yes that is what i meant, mine is for Mac desktop though.
Since the Mac IDE does not have Auto Layout, it is kind of far fetched.
The important thing is that Kareem got it working.