Hide / show part of the window at the touch of a button

I have a simple form containing the main view, as well as some text fields and the Add button, which I use to add data that is displayed in the main view (and stored in a text file). I want to add a small button that will toggle the hide / show of the add controls. Usually this button is a small square containing two arrows pointing up / down depending on the state. How to do it?

(Sorry for the terrible title, but I don't know what to call it. Can someone tell me?)

+4
source share
5 answers

I do not think that there is something built-in in WinForms for this. When I needed to do something like this, I just changed the height of the form ...

+2
source
this.ClientSize = new System.Drawing.Size(required_width, required_height); 

use bool to hide / show

+2
source

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

+1
source

I think the word you are looking for is β€œFoldable panel”.

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

+1
source

I suggest you use the SplitContainer control and play with the Panel2.Collapsed property, putting it in true or false

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

+1
source

Source: https://habr.com/ru/post/1336966/


All Articles