How about using a static boolean variable in the Paint event.

    static bool dataLoaded;

    void LoadMyData()
    {
        dataLoaded = true;
        // ...do the work...
    }

    private void MainFrame_Paint(...)
    {
        // I am not sure if you are supposed to call the base?
        base.Paint(sender, e);

        // After the first painting start loading your data
        if (!dataLoaded)
            LoadMyData();
    }

Cheers...David

----- Original Message -----
From: "franklin gray" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, May 24, 2002 10:41 AM
Subject: Re: [DOTNET] Displaying info on loading forms


If what takes so long is data retrieval, then you can spawn a new thread in the load 
event to retrieve the data.  If it is the
actual adding the data to the form that takes so long, then you can use a timer to 
execute and then turn it off when your done.

-----Original Message-----
From: Simon Robinson [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 24, 2002 5:51 AM
To: [EMAIL PROTECTED]
Subject: [DOTNET] Displaying info on loading forms


Two purposes to this post:
1. Ask a question
2. Mention some rather amusing behavior in Windows Forms.

Questions runs... Is there any event in Windows Forms that
is raised after a Form has been loaded? My form does a lot
of processing at startup and I'd like it to display itself then
do its processing, reporting to the user on its progress as it
does it.  I tried the Load event but that seems to get invoked
just before the form is displayed.

Amusing behavior runs... While looking for solutions to the
above question I tried using the Activated event. The form
contains a Panel and progress report would be written in the panel
using Graphics.DrawString().  The result?
1. The main title bar of the form gets displayed (but not
the rest of the form)
2. The calls to Graphics.DrawString() write the text over
whatever happened to be on the screen where the form is
going to be displayed. You end up with VS.NET sitting
there with all this writing scrawled over it.
3. The form appears - but now without the writing.
This quite tickled me - though I'm intrigued as to why
it happened. I bet the Windows Forms team didn't
intend it.

Simon
---------------------------------------------------------------
Simon Robinson
http://www.SimonRobinson.com
---------------------------------------------------------------

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to