本文介绍了当我的表在C#(.NET Compact Framework的)满载通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的应用程序的一种形式,我希望做一些处理时,我的表已
I have a form in my application and I want to do some processing when my form has been
满载,但我没有事件或一些东西,我可以绑定:当载荷结束的时间。
Fully loaded but I have no event or something which I can bind to when load is finished.
有没有人有任何想法,我该怎么办呢?
Does anyone has any idea, how can I do this?
推荐答案
什么exaclty是指满载?你的意思是,加载活动已成功进行?
What exaclty mean "fully loaded" ? Do you mean, the "Load" event was successfully proceeded?
您可以这样做:
public class MyForm : Form {
protected override void OnLoad( EventArgs e ) {
// the base method raises the load method
base.Load( e );
// now are all events hooked to "Load" method proceeded => the form is loaded
this.OnLoadComplete( e );
}
// your "special" method to handle "load is complete" event
protected virtual void OnLoadComplete ( e ) { ... }
}
但如果你的意思是满载的形式被加载并显示你需要重写的OnPaint的方法了。
But if you mean "fully loaded" the "form is loaded AND shown" you need override the "OnPaint" method too.
public class MyForm : Form {
private bool isLoaded;
protected override void OnLoad( EventArgs e ) {
// the base method raises the load method
base.Load( e );
// notify the "Load" method is complete
this.isLoaded = true;
}
protected override void OnPaint( PaintEventArgs e ) {
// the base method process the painting
base.OnPaint( e );
// this method can be theoretically called before the "Load" event is proceeded
// , therefore is required to check if "isLoaded == true"
if ( this.isLoaded ) {
// now are all events hooked to "Load" method proceeded => the form is loaded
this.OnLoadComplete( e );
}
}
// your "special" method to handle "load is complete" event
protected virtual void OnLoadComplete ( e ) { ... }
}
这篇关于当我的表在C#(.NET Compact Framework的)满载通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!