开发者

C# winform removing and then adding more items to a panel control

开发者 https://www.devze.com 2023-04-05 07:27 出处:网络
Using C# Winforms, I have a panel that is to display some custom controls.I can add instances of the controls to the panel and if there are too many, the panel will scroll them.

Using C# Winforms, I have a panel that is to display some custom controls. I can add instances of the controls to the panel and if there are too many, the panel will scroll them.

myPanel.Controls.Add(myControl);

The issue comes after I start removing items from the pan开发者_StackOverflow社区el. I am using:

myPanel.Controls.Remove(myControl);
myControl.Dispose();

however when I then go to add more controls to the panel, the new ones added will not display at all.

myPanel.Controls.Add(newControl);

newControl or any subsequent controls will not be visible.

Can anyone assist with this please, thank you in advance.


You are not clearing your panels. Try this:

mypanel.Controls.clear();
0

精彩评论

暂无评论...
验证码 换一张
取 消