Performance of Panel.Control.Clear

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello folks,
for showing data from my database i use a Master-Panel which have added
Detail-Panels for each row of the dataset.
Inserting the Detail-Panels running this code

disDetails.Controls.Clear()
For Each r As DataRow In myDataSet
Dim p As myDetailPanel
p = New myDetailPanel(r)
p.Dock = DockStyle.Top
disDetails.Controls.Add(p)
p.SendToBack()
Next


If i chance to the next Masterrecord and displaying the new Detailrows
(maximum 15 rows) i have to wait 1-5 seconds.
Cause of this bad performance I inserted
"Debug.Writeline(Datetime.now.ticks)" and found that most of this time (80%)
will used for running the Controls.Clear() statement.

Thanks in advance for any help to get a better performance.

Niels
 
Hello folks,
one hour later i locate my performance problem into the DetailPanel.
I have a ComboBox on this Panel which shows data from a datatable.

The dataset for the ComboBox was filled at DetailPanels-Constructor
and was set as datasource of this ComboBox.

If i delete this ComboBox from the detailpanel or if i don't set
the datasource of the ComboBox i get a good performance.

What happend if I free the panel what slow down my program?

Any ideas?

Niels
 
Probably the combobox selected index changed event is wired to something and
is firing every time the thing is updated. Wee Windows Forms Tips and Tricks
for the solution.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
Hello Bob,
thanks for your reply.

No, the Eventhandler for selection event can't be the reason.
If i set it inactiv i get the same result.

New results of my researce:
- Setting the datasource catch a much time to.
- It runs very quick if no datasource was linked to the ComboBox
- If i create ONE dataset before creating my panels and give the reference
to its construktor i don't get a better result.

Any more ideas?
Niels

Thanks for the given links. They are very usefull.
 
Back
Top