4

I have a simple form containing a main view and also some text boxes and an "add" button that I use for adding data that is displayed in the main view (and stored in a text file). What I want to do is to add a little button that will toggle hiding/showing of the adding controls. Such button usually is a small square containing two arrowheads pointing up/down depending on the state. How do I do that?

(I'm sorry for the terrible title, but I don't know the proper name for this. Could anyone tell me?)

Daniel May
  • 8,156
  • 1
  • 33
  • 43
Nick Czt.
  • 43
  • 1
  • 3

5 Answers5

2

I don't think there's something built-in in WinForms for that. When I needed to do something similar, I just changed the Height of the form...

Ilya Kogan
  • 21,995
  • 15
  • 85
  • 141
2
this.ClientSize = new System.Drawing.Size(required_width, required_height);

use a bool for hiding/showing

Raktim Biswas
  • 4,011
  • 5
  • 27
  • 32
Ankush Roy
  • 1,621
  • 2
  • 15
  • 25
1

You can use the forms Height property and the controls could be hidden with Control.Visible = false

Matten
  • 17,365
  • 2
  • 42
  • 64
1

I think the word you're looking for is "Collapsible panel".

A quick google/codeproject search will provide you with some links:

yorah
  • 2,653
  • 14
  • 24
1

I suggest you use a SplitContainer control and play with the Panel2.Collapsed property by sitting it to true or false

put the control that you want to hide/show inside panel2 and put the button in panel1. Change the Orientation property to Vertical, and there you go

Stefan
  • 5,203
  • 8
  • 27
  • 51
mustafabar
  • 2,317
  • 6
  • 31
  • 47