Click here to Skip to main content
15,899,025 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
I Have A User Control that put a panel on Bottom of it , this panel Contains Some Controls . I Want To Invisible This Panel In Some Cases At Run time But When I do That Under This Panel visible Parent User Controls Body , I wanna to have my forms to show under that What Can I Do ? Please Help Me... Thanks
Posted
Comments
BillWoodruff 22-Dec-13 15:48pm    
I think you mean that when you hide the bottom Panel in the UserControl, you also want to decrease the Height of the UserControl, so your Form is visible in the area the bottom Panel covered when it was displayed.

I assume this is a Windows Forms related question, and, if that is the case, there is a fairly easy way to accomplish what I just described.

Please confirm if this is what you want to do, or please clarify what you are trying to do.

There's a complete working WinForms example of a Collapsible UserControl (source and .exe files) here: [^].

This Project is compiled against .NET 3.0.

It demonstrates the UserControl resizing itself as a Panel at the bottom is made visible, or hidden by the user at run-time. It demonstrates control of the UserControl Panel visibility both from the Form it is sited in, and from within the UserControl.

It also demonstrates taking into account the need to adjust the UserControl when it's changed so that the Padding factor of the UserControl is taken into account, and the UserControl maintains a consistent "virtual border."

If my assumptions about your goal (expressed in my comment to your OP) are correct, creating a collapsible UserControl (or Panel), where one ContainerControl is made visible, or is hidden, and the UserControl/Panel resizes itself to fit the current contents ... is something I have done frequently.

imho, easy ... once you've done it once :) I have been meaning to write this up for CodeProject, so, this is kind of the "first draft."

Unfortunately, there are real problems with the AutoSize Property of both UserControls and ContainerControls, like Panels, in WinForms: once you have Controls sited within these containers that are Docked, you are going to have problems at run-time. If you thought you could use AutoSize, forget it.

The only alternative I know of is the kind demonstrated in this example.

Happy Holidays !

Disclaimer: This code example is provided for educational purposes only; I make no commitment to fix/improve/maintain the code as it is now. Of course, I welcome any bug-reports. At the point this is turned into a CP article, or Tip/Trick, I will support the code.
 
Share this answer
 
And what could make it a problem?
C#
Panel Footer = //...
//...
Footer.Visible = false; 


—SA
 
Share this answer
 
Comments
Aydin Homay 23-Dec-13 23:43pm    
I agree with sergey you can do it with panel visiable property and if you want make a collapsible panel and showing a little panel when you collapsed, you can decrease you panel height, however if you create your own panel user control you can use more facilities ;-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900