[英]Panel in Windows Forms Application not clearing
I'm working on my project: [Beer Pong Management System][1], a Windows Forms application. 我正在研究我的项目:[Beer Pong管理系统] [1],这是Windows Forms应用程序。 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.
简而言之,我创建了一个TabControl,第一个选项卡页面包含设置和设置,第二个页面带有括号。
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(). 我尝试将MatchUp设置为null,我尝试了dispose(),close()。 even Parent.Controls.Remove().
甚至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 anyone 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 [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; 只需传递您添加了控件的tabPage或Panel; 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.
如果控件不在列表中,则也不应绘制控件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.