I am trying to make a collapsible panel in win forms. I can decrease the height to make it looks like animated collapsing however I could not expand it as the original design height is lost after the collapsing.
while (panel1.Height > label1.Height)
{
panel1.Height--;
}
The above code animate the panel collapsing. But how do I expand it back as the panel1.Height
now equals to label1.Height
? How do I get the design stage panel1.Height
? Is there a method to get the design size of the panel?
I do not wish to put the original height during collapsing into a stored variable as I could have hundreds of the panel. Also I do not wish to hard code the height as all panel during design will have different heights.