Panel in Windows Forms Application not clearing
I'm working on my project: [Beer Pong Management System][1], a Windows Forms application. I am currently trying to add a whole tournament mode to it. In a nutshell, I've created a TabControl, with the first tab page with the settings and setup and the second page the brackets.
There is a feature for each of the match-ups, that once there is a winner is decided, a yellow cancel button will appear in order to revert the tournament. However my issue is when i click the button the next match-up does not get removed in the series is going. See below:
Image Here(not high enough rep to insert image)
I have tried to set the MatchUp to null, I've tried dispose(), close(). even Parent.Controls.Remove(). Even after I switch tabs which is supposed to clear all, they still sit there when i come back.
I have a feeling I might be loosing a reference or something because I can't even push new teams into them, they just sit there with their buttons.
Does a开发者_运维问答nyone have any tips or know of any known issues that might be causing this? Thanks.[1] _http://www.cs.rit.edu/~rmb1201/pages/code.shtml
Maybe this snippet can help you identify the problem:
public string GetControlSummary(Control rootControl, int level)
{
string result = "";
foreach (Control childControl in rootControl.Controls)
{
result += new string(' ', level * 4) + childControl.Name + " (" + childControl.GetType().Name + ")\r\n";
result += GetControlSummary(childControl, level + 1);
}
return result;
}
Just pass the tabPage or Panel you added your controls to; it will give you a list of all controls and sub-controls you have added. If the controls are not in the list, they also shouldn't be painted.
精彩评论