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,096
  • 1
  • 31
  • 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,366
  • 15
  • 81
  • 136
2
this.ClientSize = new System.Drawing.Size(required_width, required_height);

use a bool for hiding/showing

Raktim Biswas
  • 3,891
  • 5
  • 25
  • 31
Ankush Roy
  • 1,611
  • 2
  • 15
  • 25
1

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

Matten
  • 17,025
  • 1
  • 40
  • 63
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,588
  • 13
  • 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
  • 4,997
  • 8
  • 26
  • 51
mustafabar
  • 2,287
  • 6
  • 31
  • 47