简体   繁体   中英

How to create an overlay part of control in Winforms C#?

I need to create a custom control that has an expandable part as a panel and a textbox part. The expandable part is a panel, that will either be visible or invisible. But when the panel is visible/expanded directly under the textbox, I do not want the adjacent controls to shift down below the panel, but the panel should just overlay the controls that are there just under the custom control. How would I implement this in Winforms C# project? I am open to using user control for this scenario.

Thanks Sunil

I think your implementation of expanding and collapsing is not the best, because you are just overlaying the controls instead of hiding them. One of the disadvantages is that the overlaid controls might by focussed by pressing tab and they might have a value which I think it is out of target.

I would suggest another implementation by creating two panels (one for the header and another one for the content) and when the collapse button is pressed then the content's panel will be hidden by sitting its Visible property to false and its Hight to 0 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM