开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜