Click here to Skip to main content
15,898,134 members
Home / Discussions / C#
   

C#

 
QuestionPerformanceCounter problems Pin
JMichael246820-Sep-07 8:53
JMichael246820-Sep-07 8:53 
AnswerRe: PerformanceCounter problems Pin
JMichael246821-Sep-07 4:36
JMichael246821-Sep-07 4:36 
QuestionSpeed up Treeview [Solved] Pin
DaveyM6920-Sep-07 8:52
professionalDaveyM6920-Sep-07 8:52 
AnswerRe: Speed up Treeview Pin
Dave Kreskowiak20-Sep-07 9:12
mveDave Kreskowiak20-Sep-07 9:12 
GeneralRe: Speed up Treeview Pin
DaveyM6920-Sep-07 10:55
professionalDaveyM6920-Sep-07 10:55 
GeneralRe: Speed up Treeview Pin
Scott Dorman20-Sep-07 10:58
professionalScott Dorman20-Sep-07 10:58 
GeneralRe: Speed up Treeview Pin
DaveyM6920-Sep-07 11:13
professionalDaveyM6920-Sep-07 11:13 
AnswerRe: Speed up Treeview [modified] Pin
Scott Dorman20-Sep-07 10:56
professionalScott Dorman20-Sep-07 10:56 
Depending on how you are actually building up the nodes, collect them in a List<TreeNode> collection first. Once you are done creating them, call AddRange instead of Add and pass in the list (you will need to call List.ToArray() to pass it in as AddRange only accepts arrays).

Using AddRange is considerably faster than calling Add repeatedly, especially for large amounts of adds.

As Dave mentioned, you should also call BeginUpdate and EndUpdate as well as SuspendLayout, ResumeLayout to prevent the UI from repainting after each add. (I don't think BeginUpdate, EndUpdate implicitly make the calls to SuspendLayout, ResumeLayout, but if they do you wouldn't need to call both explicitly.)

[modification at 17:01 Thursday 20th September, 2007]
The SuspendLayout, ResumeLayout calls won't actually buy you anything in this case. The BeginUpdate, EndUpdate are the ones you want to use.
[/modification]


Scott.

—In just two days, tomorrow will be yesterday.

[Forum Guidelines] [Articles] [Blog]

GeneralRe: Speed up Treeview Pin
Pete O'Hanlon20-Sep-07 11:19
mvePete O'Hanlon20-Sep-07 11:19 
GeneralRe: Speed up Treeview Pin
Scott Dorman20-Sep-07 11:37
professionalScott Dorman20-Sep-07 11:37 
GeneralRe: Speed up Treeview Pin
DaveyM6920-Sep-07 11:43
professionalDaveyM6920-Sep-07 11:43 
AnswerRe: Speed up Treeview Pin
DaveyM6920-Sep-07 11:31
professionalDaveyM6920-Sep-07 11:31 
GeneralRe: Speed up Treeview Pin
Scott Dorman20-Sep-07 18:26
professionalScott Dorman20-Sep-07 18:26 
GeneralRe: Speed up Treeview Pin
DaveyM6921-Sep-07 1:05
professionalDaveyM6921-Sep-07 1:05 
GeneralRe: Speed up Treeview Pin
Scott Dorman21-Sep-07 4:49
professionalScott Dorman21-Sep-07 4:49 
GeneralRe: Speed up Treeview Pin
Pete O'Hanlon21-Sep-07 9:12
mvePete O'Hanlon21-Sep-07 9:12 
GeneralRe: Speed up Treeview Pin
DaveyM6921-Sep-07 3:36
professionalDaveyM6921-Sep-07 3:36 
GeneralRe: Speed up Treeview Pin
Scott Dorman21-Sep-07 4:51
professionalScott Dorman21-Sep-07 4:51 
GeneralRe: Speed up Treeview Pin
DaveyM6921-Sep-07 5:50
professionalDaveyM6921-Sep-07 5:50 
GeneralRe: Speed up Treeview Pin
DaveyM6921-Sep-07 7:55
professionalDaveyM6921-Sep-07 7:55 
GeneralRe: Speed up Treeview Pin
Scott Dorman21-Sep-07 8:06
professionalScott Dorman21-Sep-07 8:06 
GeneralRe: Speed up Treeview Pin
igetorix11-May-08 5:49
igetorix11-May-08 5:49 
QuestionDataTable does not contain definition for 'Controls'???? Pin
ss.mmm20-Sep-07 8:43
ss.mmm20-Sep-07 8:43 
AnswerRe: DataTable does not contain definition for 'Controls'???? Pin
Dave Kreskowiak20-Sep-07 9:09
mveDave Kreskowiak20-Sep-07 9:09 
GeneralRe: DataTable does not contain definition for 'Controls'???? Pin
ss.mmm20-Sep-07 9:30
ss.mmm20-Sep-07 9:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.