Solved

SLOW SHOWING WINDOWS FORM

Posted on 2012-12-28
15
182 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
  • 7
  • 4
  • 3
  • +1
15 Comments
 
LVL 85

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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 85

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 400 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 85

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 100 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 85

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

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

773 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