问题描述
在p1City Control中,我有一个重新排序某些图像的Reorder()方法。
当我按下Tab'按钮'时,在断点调试时没有达到p1City Control里面的public p1City()。
开始时达到罚款。 (我不能把所有的代码都放在太复杂的地方)但请相信我,直到我开始按下按钮才行。
我在想
#1
void Tab01_Click(对象发送者,EventArgs e)
Controls.Remove(p1city);
是否正在删除p1city的事件?
-OR-
#2
或我应该手动删除事件并重新添加它们?
删除它:[this.Paint - = new PaintEventHandler(p1City_Paint);](例如)
我现在被卡住了......
//在p1City中控制
public p1City()
{
InitializeComponent();
// if(tab1Global.isEmpy)
{
ReOrder();
tab1Global.isEmpy = false;
}
}
public void InitializeEvents()
{
this.Paint + = new PaintEventHandler(p1City_Paint);
this.MouseMove + = new MouseEventHandler(p1City_MouseMove);
}
//在Form1中
public Form1()
{
InitializeComponent();
DoubleBuffered = true; //还是Big Flickerings!但可管理的
Controls.Clear();
InitializeButtonsEvents();
InitializeTabsEvents();
p1city.InitializeEvents();
{
//
Tab Tab01 = new Tab(); //这是一个名为'Tab'的控件,用于某些自定义绘图
void InitializeTabsEvents()
{
Tab01.Click + = new EventHandler(Tab01_Click);
Tab02.Click + = new EventHandler(Tab02_Click);
}
p1City p1city = new p1City();
void Tab01_Click(对象发送者,EventArgs e)
{
//对于我有的每个标签,我从表格
Controls.Remove(p1city)中删除其他特定控件;
//然后我添加了corespondent标签控件
Controls.Add(p1City); p1City.BringToFront();
}
我尝试过:
//对于我有的每个标签,我从表格中删除其他特定控件
Inside p1City Control, I have a Reorder() method that is reordering some images.
When I press the Tab 'button', the "public p1City()" inside p1City Control is not reached at breakpoint debugging.
Is reached fine when it starts though. (i cant put all the code since is too complicated) but trust me, it works until i start pressing buttons.
I am thinking
#1
void Tab01_Click(object sender, EventArgs e)
Controls.Remove(p1city);
is removing the event of p1city?
-OR-
#2
or I should remove manually the events and add them back again?
remove it with : [this.Paint -= new PaintEventHandler(p1City_Paint);] (for example)
I am so stuck right now...
//inside p1City Control public p1City() { InitializeComponent(); // if (tab1Global.isEmpy) { ReOrder(); tab1Global.isEmpy = false; } } public void InitializeEvents() { this.Paint += new PaintEventHandler(p1City_Paint); this.MouseMove += new MouseEventHandler(p1City_MouseMove); } //in Form1 public Form1() { InitializeComponent(); DoubleBuffered = true; //still Big Flickerings! but manageable Controls.Clear(); InitializeButtonsEvents(); InitializeTabsEvents(); p1city.InitializeEvents(); { // Tab Tab01 = new Tab(); //it's a control named 'Tab' for some custom drawing void InitializeTabsEvents() { Tab01.Click += new EventHandler(Tab01_Click); Tab02.Click += new EventHandler(Tab02_Click); } p1City p1city = new p1City(); void Tab01_Click(object sender, EventArgs e) { // for each tab i have, i remove other specific controls from the form Controls.Remove(p1city); //then I add the corespondent tab control Controls.Add(p1City); p1City.BringToFront(); }
What I have tried:
// for each tab i have, i remove other specific controls from the form
这篇关于当按下按钮时,我无法(重新)初始化我的控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!