Emb*_*rja 2 .net c# compact-framework
我的应用程序中有一个表单,我希望在表单完成后进行一些处理
完全加载但我没有任何事件或我可以在加载完成时绑定的东西.
有谁有任何想法,我该怎么做?
什么exaclty意味着"满载"?你的意思是,"加载"事件成功进行了吗?
你可以这样做:
public class MyForm : Form {
protected override void OnLoad( EventArgs e ) {
// the base method raises the load method
base.OnLoad( 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 ) { ... }
}
Run Code Online (Sandbox Code Playgroud)
但如果你的意思是"完全加载","表单已加载并显示",你也需要覆盖"OnPaint"方法.
public class MyForm : Form {
private bool isLoaded;
protected override void OnLoad( EventArgs e ) {
// the base method raises the load method
base.OnLoad( 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 ) { ... }
}
Run Code Online (Sandbox Code Playgroud)