archer_coal Posted June 21, 2003 Posted June 21, 2003 These are the things that drive me nuts. Want to join me for the ride? Great! Here's what you do. ( yes there is a question with this) Step 1. To a form add Panel1(set its borderstyle to FixedSingle) , 4 listboxes named lb1,lb2, lb3, lb4 and a button Step 2. Make the panel large enough to fit all 4 listboxes inside then place them inside the panel evenly spaced Step 3. Anchor the listboxes as follows: lb1 (Top,Left) lb2( Top, Right) lb3 (Bottom, Left) lb4 (Bottom, Right) Step 4. Make your form considerably larger than the panel Step 5. Add the following code to the button's click event Panel1.Height = Me.Height / 2 Panel1.Width = Me.Width / 2 lb1.Height = (Panel1.Height / 2) lb2.Height = (Panel1.Height / 2) lb3.Height = (Panel1.Height / 2) lb4.Height = (Panel1.Height / 2) lb1.Items.Add(lb1.Height) lb1.Items.Add(lb1.Width) lb1.Items.Add(Panel1.Height) lb1.Items.Add(Panel1.Width) lb2.Items.Add(lb2.Height) lb2.Items.Add(lb2.Width) lb3.Items.Add(lb3.Height) lb3.Items.Add(lb3.Width) lb4.Items.Add(lb4.Height) lb4.Items.Add(lb4.Width) lb1.Width = (Panel1.Width / 2) lb2.Width = (Panel1.Width / 2) lb3.Width = (Panel1.Width / 2) lb4.Width = (Panel1.Width / 2) Panel1.Refresh() Step 6. Scratch your head and wonder why the only listbox behaving correctly is lb1. The others seem to drift off into the seams of the panel even though they are anchord and should not. Anyone have an idea why this happens or did I take the short bus to school? I'm assuming the anchor fires before the button click and therefore the x,y Drawing points of the listboxes are etched in stone before the boxes are resized/redrawn? It should be a simple task to keep controls uniform in the event of resizing a form! :confused: :mad: Quote
Moderators Robby Posted June 21, 2003 Moderators Posted June 21, 2003 Was the above code given to you or did you make it up yourself? If the latter then I guess we can change it, or did you just want an expanation as to why it's reacting this way? Quote Visit...Bassic Software
archer_coal Posted June 24, 2003 Author Posted June 24, 2003 RE Understanding WHY its doing what its doing would be great! If the code is faulty then help with fixing it would be great too. thnx My appologizes if the initial thread was not clear on that. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.