controls automatically move when others are resized

aewarnick

Senior Contributor
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 he's also resizing (and from what I can tell moving) the TextBoxes, meaning that a panel would only partially work. Then again, I'm not sure I completely understand what he's 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 you're doing is beyond the ordinary. I'd 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 you're having them do. It's fine, and it might work for you, but it is not the standard.
 
I wouldn't mind using panels but I didn't think that they would act the same as they will my way, will they?
 
Why don't 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:
aewarnick said:
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.
That's exactly what I thought - and that's exactly what I described with the panels.

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