Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / August 2004

Tip: Looking for answers? Try searching our database.

controls.Add

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Stivo - 06 Aug 2004 20:05 GMT
I use very often custom controls in panels.
But I always have performance issues (on all computer, not only on mine).

I always have this kind of code :

panel1.controls.clear
While ...
       r = New uMyControl(param1,param2)
       Panel1.Controls.Add(r)
       r.Dock = DockStyle.Top
       Panel1.Controls.SetChildIndex(r, 0)
End While

I tried to build a list of controls first and then use the control.addRange
method. But it seems that the increase of performance is just 5-10%. It is
still too slow, especially when the the size of controls is more than 20.

What is the best trick to improve that ?

Thanks
Ignacio Machin \( .NET/ C#  MVP \) - 06 Aug 2004 20:51 GMT
Hi Stivo,

I use a code similar to your and it works fine on a PPC device,  these are
some hints that may or may not help you
1- Use Control.Add only, no SetChildIndes , why are you using this method in
the first place??? This is a VERY heavy operation I think, just remove it
and the performance will increase !!!

2- use Control SuspendLayout/ ResumeLayout on the panel around the while
loop

Cheers,

Signature

Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

> I use very often custom controls in panels.
> But I always have performance issues (on all computer, not only on mine).
[quoted text clipped - 16 lines]
>
> Thanks
Stivo - 06 Aug 2004 21:13 GMT
Thanks for your post Ignacio !

Here is my answer:

1) I use SetChildIndex to put again the right order. Ok, I admit that I can
avoid to use SetchildIndex by inverting the order in which I create the
control, but I like to have a code as logical as it can.

2) I already tried SuspendLayout and ResumeLayout(true), but very often
(it's working only in a few cases) the docking is no more working. Eventhough
I call ResumeLayout(true) to resume the layout the docking is not respected
and all controls are behind each other, we can see only one in the panel.

I have framework .NET 1.1

"Ignacio Machin ( .NET/ C#  MVP )" wrote:

> Hi Stivo,
>
[quoted text clipped - 30 lines]
> >
> > Thanks
Ignacio Machin \( .NET/ C#  MVP \) - 09 Aug 2004 14:37 GMT
> Thanks for your post Ignacio !
>
[quoted text clipped - 3 lines]
> avoid to use SetchildIndex by inverting the order in which I create the
> control, but I like to have a code as logical as it can.

This  has NOTHING to do with code logicalness ,  it's a huge overload, drop
it !!!

cheers,

Signature

Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.