当我的表在C#(.NET Compact Framework的)满载通知?我的、通知、Compact、NET

2023-09-03 15:26:56 作者:张艺兴是我正室°

我在我的应用程序的一种形式,我希望做一些处理时,我的表已

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 ) { ... }
}