A是UserControl、B、C都是用户控件。
B继承自A、C继承自B,即A->B->C,
在B和C的构造函数里,我分别写了this.Paint+=xxB_Paint();this.Paint+=xxC_Paint();
在B和C各自的类里定义了xxB_Paint();xxC_Paint();
跟踪发现,当我运行时把C拖放到一个Panel里,C能正确显示出来,但是xxB_Paint();xxC_Paint()函数都没有执行,是咋回事呢?
public partial class ucMetaItem : DevExpress.XtraEditors.XtraUserControl
{
public ucMetaItem()
{
InitializeComponent();
...
this.Paint += UcMetaBaseItem_Paint;
...
}
private void UcMetaBaseItem_Paint(object sender, PaintEventArgs e)
{
//调试发现此函数从未执行过
}
}
public partial class ucRealItem : ucMetaItem
{
public ucRealItem()
{
InitializeComponent();
...
this.Paint += UcRealItem_Paint;
...
}
private void UcRealItem_Paint(object sender, PaintEventArgs e)
{
//调试发现此函数从未执行过
}
}
public partial class ucSonRealItem : ucRealItem
{
public ucSonRealItem()
{
InitializeComponent();
...
this.Paint += UcSonRealItem_Paint;
...
}
private void UcSonRealItem_Paint(object sender, PaintEventArgs e)
{
//调试发现此函数从未执行过
}
}
int main()
{
ucSonRealItem usoni=new ucSonRealItem();
panelcontainer.controls.add(usoni);
//usoni能正常添加到panel中,显示正常,但是两个paint函数没有执行过,而我想在paint函数里执行一个gdi绘图的操作
}
※ 修改:·moneybox 于 Jul 30 10:41:26 2022 修改本文·[FROM: 106.39.42.*]
※ 来源:·水木社区
http://www.mysmth.net·[FROM: 106.39.42.*]
修改:moneybox FROM 106.39.42.*
FROM 106.39.42.*