?
Solved

SLOW SHOWING WINDOWS FORM

Posted on 2012-12-28
15
Medium Priority
?
191 Views
Last Modified: 2013-01-04
Hi All,

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.
0
Comment
Question by:emi_sastra
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
  • 3
  • +1
15 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 38728745
"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...
0
 
LVL 1

Author Comment

by:emi_sastra
ID: 38728754
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.
0
 
LVL 13

Expert Comment

by:themrrobert
ID: 38728763
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

End Sub


Here is how to use background worker: http://msdn.microsoft.com/en-us/library/cc221403%28v=vs.95%29.aspx
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 38728765
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.
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 1600 total points
ID: 38729252
0
 
LVL 1

Author Comment

by:emi_sastra
ID: 38730584
Hi Idle_Mind and  themrrobert,

There is no big difference with between shown and load event.

Thank you.
0
 
LVL 86

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 400 total points
ID: 38731140
You could also try forcing a repaint before the other loading code continues:
Me.Show()
Application.DoEvents()
' ... rest of the loading code ...

Open in new window

0
 
LVL 1

Author Comment

by:emi_sastra
ID: 38731579
-You could also try forcing a repaint before the other loading code continues:
At what event ?

Thank you.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 38731647
The Load() event...or wherever your code that loads the controls is.
0
 
LVL 1

Author Comment

by:emi_sastra
ID: 38731773
Yes, it improve showing form.

I would like also consider asynchronous data loading by emoreau.

Thank you.
0
 
LVL 1

Author Comment

by:emi_sastra
ID: 38731775
Hi emoreau,

Where to put the asynchronous data loading, at what event in order to make the data appear after form has shown?

Thank you.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 38732468
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.
0
 
LVL 1

Author Comment

by:emi_sastra
ID: 38733855
-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.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 38734420
create a LoadData method. this method will contain the BeginExecuteXXX and everything to get the results.

Call this method from the form_load event
0
 
LVL 1

Author Closing Comment

by:emi_sastra
ID: 38745933
Hi All,

Thank you very much for your help.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

766 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question