controls automatically move when others are resized

aewarnick

Well-known member
Joined
Jan 29, 2003
Messages
1,031
I have a form that has text boxes on it and labels that I would like to resize, but when they are resized I need the other boxes to move down so that they can be seen. I know that I can manually do this by using Location=new Point(); but that will take a long time. Is there an easier way?
 
Create a panel to contain all the textboxes that you want to align together. Set each of them to Dock = Top and as you resize each, the ones below will move accordingly. You can then do the same thing with the labels which will go into another panel to the left of the first.
 
The problem is hes also resizing (and from what I can tell moving) the TextBoxes, meaning that a panel would only partially work. Then again, Im not sure I completely understand what hes trying to do, so you might have hit the nail on the head. *Shrug*
 
You are right Derek, I am moving the other boxes down when one above it is resized because if they did not move then the user could not see the boxes under it.

So, I have to do it manually in that case?

And, it is awkward to do it the way I am? It seems reasonable to me? I would think alot of people would do it this way. But what do I know, I just started.
 
You should take a shot at the method TechnoTone mentioned above, before you go ahead with doing it manually.

But yes, what youre doing is beyond the ordinary. Id strongly suggest organizing your data input methodology differently, either using a tabbed dialog control or a ListBox menu/panel system. Nowhere in a professionally designed business application will you see TextBoxes doing what youre having them do. Its fine, and it might work for you, but it is not the standard.
 
I wouldnt mind using panels but I didnt think that they would act the same as they will my way, will they?
 
Why dont you just add a splitter bar between each textbox, or the panels TT suggested? This will handle to resizing for you. (Set the dock style of the splitter also to top)

EDIT: To clarify - use a panel to hold a label and textbox. Dock the label to left and the textbox to fill. Add this panel (which dock is set to top) to your container and add a splitter afterwards (dock set to top). Note that you will have to add these controls in reverse order to what you want to see on the screen..
 
Last edited by a moderator:
Originally posted by aewarnick
You are right Derek, I am moving the other boxes down when one above it is resized because if they did not move then the user could not see the boxes under it.
Thats exactly what I thought - and thats exactly what I described with the panels.

I have attached a form demonstrating what I mean:
 
Back
Top