拦截SetChildIndex的值更改 [英] Intercepting the value change of SetChildIndex
本文介绍了拦截SetChildIndex的值更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在.NET CF表单中,我有多个面板.我想拥有一个属性,该属性应该始终被告知面板是否在前面.
In a .NET CF-form i have multiple panels. I want to have a property that should always be informed about if a panel is in the front.
可以使用GetChildIndex()方法完成此操作吗?
Can this be done using the GetChildIndex() method?
如果是,我如何拦截对SetChildIndex()的更改?
If yes, how do i intercept the change to SetChildIndex()?
预先感谢
推荐答案
对于每个对将来使用感兴趣的人:
For everybody who is interested for future use:
只需为每个面板的Paint事件添加一个新的事件处理程序,例如:
simply add a new event handler for the Paint event of each panel, for example:
panel1.Paint += new PaintEventHandler(panel1_Paint);
panel2.Paint += new PaintEventHandler(panel2_Paint);
,并且在每个事件处理程序中只需调用一个Method即可检索所有面板的状态,如下所示:
and in each of the event handlers just call a Method which retrieves the state of all the panels like so:
void panel2_Paint(object sender, PaintEventArgs e)
{
GetPanelStates();
}
void panel1_Paint(object sender, PaintEventArgs e)
{
GetPanelStates();
}
void GetPanelStates()
{
Panel2IsInFront = panel2.Parent.Controls.GetChildIndex(panel2) == 0;
Panel1IsInFront = panel1.Parent.Controls.GetChildIndex(panel1) == 0;
}
这篇关于拦截SetChildIndex的值更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文