I have experienced of slow showing windows form, because I have to load huge data to datagridview or other tasks.
I want to show the form first then after that loading data to gridview.
How could I solve this problem ?
Thank you.
Visual Basic.NET
Last Comment
emi_sastra
8/22/2022 - Mon
Mike Tomlinson
"I want to show the form first then after that loading data to gridview."
Wire up the Shown() event of the Form, and place your code to load the grid in there. You could also use the BackgroundWorker() control to do the query in the background...
emi_sastra
ASKER
Hi Idle_Mind,
-Wire up the Shown() event of the Form
I don't get this ?
-You could also use the BackgroundWorker() control to do the query in the background...
Any sample of it ?
Thank you.
themrrobert
Double click on the form and select the Shown() event. Put your code in there.
(my code is just a sample you need to get the event from the IDE.
Public Sub Shown()
'Load Database code
Select the Form. In the Properties Pane, bottom right by default, click on the "Lightning Bolt" icon. Scroll down and find the "Shown" entry and double click to the right of it.
you can call the BeginExecuteXXX directly from the form_load event but I would create a LoadData method (called by the form_load event for that purpose.
emi_sastra
ASKER
-you can call the BeginExecuteXXX directly from the form_load event but I would create a LoadData method (called by the form_load event for that purpose.
- I am sorry, miss your point. BeginExecuteXXX at load event but LoadData at load event also ?
Thank you.
Éric Moreau
create a LoadData method. this method will contain the BeginExecuteXXX and everything to get the results.
Wire up the Shown() event of the Form, and place your code to load the grid in there. You could also use the BackgroundWorker() control to do the query in the background...