![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have a form which allows users to relaod data at runtime. Unfortunately, the operation of reloading and/or adding new criteria records is very slow and you can see all of the control being painted slowly over the 3 second transacation. I would like to suspend all painting, redrawing and refreshing of the panel that contains all of these user controls (test case as over 4 user controls that are made up of 10-20 elements each (controls and other user controls)) until after everything has been added. I tried a varierty of things, include SuspendLayout, override OnPaint and only calling base.OnPaint() when I set a special flag, etc... It is not working, when each control is added to another, painting occurs. I have even tried dubble buffering sets... I thought I knew how onPaint worked before I tackle this problem, but now I'm pretty confused as it seems drawing is occurring outside of the onPaint events. Before I started playign with code I set some counters to see how often onPaint was called for the most nested userControl I had in the form when I was creating a new series of criteria record. I was getting counts of 40-50 onPaint calls during the creation process. Below is a test refresh function in which I clear the panel and re- create everything... I'm using this to try and find a solution for the painting problems. The idea if to have a blank screen until everything is created and then paint the screen, rather than seeing all sorts of graphic artifacts for a couple of seconds... private void RefeshCriteria(SortedList<int, CriteriaBase sortedCriteria) { Refreshing = true; // // Clear out the old controls. // panelCriteria.Controls.Clear(); this.SuspendLayout(); if (sortedCriteria == null) return; // // Add each of our criteria controls. We have to add the control in reverse list // order since the MS docking puts the last control added on the top of the list // when using Top dock style. // for (int sequence = sortedCriteria.Count; sequence > 0; sequence--) { CriteriaBase criteria = sortedCriteria[sequence]; CriteriaListComponentControl criteriaControl = new CriteriaListComponentControl( criteria, filterControls, valueControls, showMessages); criteriaControl.Changed += new ChangedDelegate(OnChanged); criteriaControl.OnSelect += new SelectedDelegate(CriteriaSelected); criteriaControl.Dock = DockStyle.Top; criteriaControl.SuspendLayout(); panelCriteria.Controls.Add(criteriaControl); criteriaControl.ResumeLayout(); } Refreshing = false; this.ResumeLayout(); this.PerformLayout(); } |
#3
| |||
| |||
|
|
Your best bet is to revisit the user controls themselves to see if you have inefficiencies in the children that are holding things up. |
#4
| |||
| |||
|
|
On Sep 15, 2:12 am, "Bob Powell [MVP]" <b... (AT) spamkillerbobpowell (DOT) net wrote: Your best bet is to revisit the user controls themselves to see if you have inefficiencies in the children that are holding things up. I've come across something that is working ok, but is much slower than expected.. I create everything in a panel is not linked to anything and then once all the children are created, I add the panel to the screen. For my test case is takes about 3 seconds to create everything on the panel. The suprising part is that it takes 1.5 seconds for the program to add the panel to the screen. It looks quite a bit better than adding all the controls directly to the screen of course, but I assumed it would take a fraction of a secont to render and I'm confused as to why it would take so long to render a bunch of textboxes, checkboxes and dropdowns (I have roughly 10 controls bundled into a user control that represents a row and I have 5 rows). |
#5
| |||
| |||
|
|
Do you have other code in these controls such as changed event handlers that in-turn fire off an Invalidate or something. These can cause "ringing" poblems where the whole system goes mad sending updates for a while and then takes a while to setle down. -- -- Bob Powell [MVP] Visual C#, System.Drawing Ramuseco Limited .NET consultinghttp://www.ramuseco.com Find great Windows Forms articles in Windows Forms Tips and Trickshttp://www.bobpowell.net/tipstricks.htm Answer those GDI+ questions with the GDI+ FAQhttp://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. "tribbles" <shiret... (AT) yahoo (DOT) com> wrote in message news:1190050310.148258.239290 (AT) 22g2000hsm (DOT) googlegroups.com... On Sep 15, 2:12 am, "Bob Powell [MVP]" <b... (AT) spamkillerbobpowell (DOT) net wrote: Your best bet is to revisit the user controls themselves to see if you have inefficiencies in the children that are holding things up. I've come across something that is working ok, but is much slower than expected.. I create everything in a panel is not linked to anything and then once all the children are created, I add the panel to the screen. For my test case is takes about 3 seconds to create everything on the panel. The suprising part is that it takes 1.5 seconds for the program to add the panel to the screen. It looks quite a bit better than adding all the controls directly to the screen of course, but I assumed it would take a fraction of a secont to render and I'm confused as to why it would take so long to render a bunch of textboxes, checkboxes and dropdowns (I have roughly 10 controls bundled into a user control that represents a row and I have 5 rows).- Hide quoted text - - Show quoted text - |
#6
| |||
| |||
|
|
On Sep 18, 2:21 am, "Bob Powell [MVP]" <b... (AT) spamkillerbobpowell (DOT) net wrote: Do you have other code in these controls such as changed event handlers that in-turn fire off an Invalidate or something. These can cause "ringing" poblems where the whole system goes mad sending updates for a while and then takes a while to setle down. -- -- Bob Powell [MVP] Visual C#, System.Drawing Ramuseco Limited .NET consultinghttp://www.ramuseco.com Find great Windows Forms articles in Windows Forms Tips and Trickshttp://www.bobpowell.net/tipstricks.htm Answer those GDI+ questions with the GDI+ FAQhttp://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. "tribbles" <shiret... (AT) yahoo (DOT) com> wrote in message news:1190050310.148258.239290 (AT) 22g2000hsm (DOT) googlegroups.com... On Sep 15, 2:12 am, "Bob Powell [MVP]" <b... (AT) spamkillerbobpowell (DOT) net wrote: Your best bet is to revisit the user controls themselves to see if you have inefficiencies in the children that are holding things up. I've come across something that is working ok, but is much slower than expected.. I create everything in a panel is not linked to anything and then once all the children are created, I add the panel to the screen. For my test case is takes about 3 seconds to create everything on the panel. The suprising part is that it takes 1.5 seconds for the program to add the panel to the screen. It looks quite a bit better than adding all the controls directly to the screen of course, but I assumed it would take a fraction of a secont to render and I'm confused as to why it would take so long to render a bunch of textboxes, checkboxes and dropdowns (I have roughly 10 controls bundled into a user control that represents a row and I have 5 rows).- Hide quoted text - - Show quoted text - I am seeing the 'event storm' occur with some debugging and profilign tools I have. My user controls directly have very few triggering events. However, I use a tab control from Infragestics to host my user control on one of its tabs and it has a couple of events being triggered hundreds of times during all of this. My current plans is to switch to the MS tab control to see if this problem goes away, as I can not descern any reasonable reason for the event storm, nor can I track exactly what is triggering it. Near as I can tell, the event storm starts when I add the panel with my user controls to the tab page. As for the creation of my user controls, they do have their own event storms going on (thus the 3 seconds) but I understand those and I'm slowly working thru them. By the time I added the user panel with my custom controls on it to the tab page, my event storm from the items changes is finished. When I add the panel, my user controls are getting 40+ refresh calls before being fully rendered. Yet none of my Changed events are firing... Also the background paint event seems to be called most often... While I am havign good success tracing what happens when I place my controls in the MS panel... I've been unable to trace through the infragestic controls to see what is going on, which is a bit frustrating... |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |