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();
精彩评论