Hello All,

i am after a little information on a query i have.

I have three forms that are fairly similar in the process that they take, the only difference is an extra textbox and different SQL DB Updates.

so what i plan to do is merge all three forms together and get the form to decide what to be depending on what the user selects (button1 , 2 or 3).

I have got the main display setup i just want to know if there is a way to hide the two spare textboxes when they are not needed (these are in the middle of the form), currently i just hide them, but by doing this the form does not look tidy when the user selects the form from button1 (theres a bit of blank space in the middle where the two textboxes are).

So my question is, is there a way to change the size of a form in the middle so what it does is hide the two other textboxes are hidden and the form looks smaller. I have googled it and found a sliding effect trick, which does look cool and i will be trying, i just thought that if i asked you guys there might be an easier way.

8 Years
Discussion Span
Last Post by finito
textBox1.Visible = false;

this.Width = 709;

Hello, i don't think you understand what i mean.

Imagine a standard windows form Width = 200, Hieght = 200 and a textboxes Location is bang on in the middle say Location 100,100.

How do i use form controls to shift the forms size in the middle rather than from the bottom so what it does is move in the middle to make the form smaller rather than from the bottom.

Heres a very simple diagram

| |
| _________ |
| |_TextBox_| |
| _________ |
| |_Button__| |

Now change size of form but change the size in the middle,

again a very simple diagram
| |
| _________ |
| |_Button__| |

Hopefully this explains what i am trying to acomplish

apologies for the way the diagrams look, they looked different in the Post area

Edited by Ap0ca1ypse: Diagrams Did not show how id imagine


this.Height = 100;

Wouldn't that just reduce the height from the bottom? Therefore hiding the button rather than the textbox?


you want to hide the textbox?

just do this textBox1.Visible = false;

Hello, yes i do, i already use this method, picture a form with 3 textboxes, one under another and a button at the bottom, this form can be gotten to by threee different button methods,

for example

if user clicks button1 form will load up with textbox1 shown and the other two hidden and the button showing.

if user clicks button2 form will load up with textbox1 & 2 showing and textbox3 hidden and the button showing.

if user clicks button3 form will show all three textboxes and the button.

now i already have this in place, what i am after is a clean up method for examples 1 & 2 as when the user sees the form there will be whitespace where the textboxes are invisible, thats ok, but to make it a bit more presentable i want to make the form smaller where these textboxes would be to reduce the whitespace.

Do you get what i mean now?


Ap0ca1ypse I understood you the first time please confirm.

Apologies finito.

I have checked the zip, but as i am at work (do not have VS on station) i will be unable to run the app until i get home, i have however read the cs files in notepad.

Am i under the assumption that what you have done is moved the textboxes around based on the button selected?

if so it sounds what i am after, i always seem to overthink simple methods, give me chance to try it at home (roughly 4 - 5 hrs) i will give it a shot (just to check its what i am after), if its good i will mark as solved.

Thanks for your time and patience.



Well I moved the buttons around, but the same code applies to textBoxes.

Edited by finito: n/a


If you simply change the Anchor property of your buttons to "Bottom, Left" then adjusting the size of the form will move them up automatically.

Edited by nick.crane: n/a


Well I moved the buttons around, but the same code applies to textBoxes.

Thanks finito that is exactly what i was after (obviously the buttons will be on different forms and the slide effect wont be noticed as it will be done on form load)

Thanks for your patience and help

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.