Click here to Skip to main content
15,890,527 members
Home / Discussions / C#
   

C#

 
AnswerRe: Speed up Treeview [modified] Pin
Scott Dorman20-Sep-07 10:56
professionalScott Dorman20-Sep-07 10:56 
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 
Hmmm...I actually just ran your sample application and your way took 409 ms while mine took 676 ms. That result bothers me for a couple of reasons:

  1. The times are very different. Granted, that is probably due to hardware differences, but I wouldn't have thought it would be that significant.
  2. The use of AddRange should still be faster.

I made one tweak to your sample, which changed the times to be within ~30 ms of each other. After several runs, it was inconclusive as to which method was consistently faster.

The change I made was in the Build(ref TreeView) function and changed the following lines:
C#
treeView.Nodes.Add(mainNode);
treeView.Nodes[0].Nodes.AddRange(childNodes.ToArray());
to
C#
mainNode.Nodes.AddRange(childNodes.ToArray());
treeView.Nodes.Add(mainNode);



Scott.

—In just two days, tomorrow will be yesterday.

[Forum Guidelines] [Articles] [Blog]

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 
AnswerRe: Data on displaying on separate forms Pin
Dave Kreskowiak20-Sep-07 8:55
mveDave Kreskowiak20-Sep-07 8:55 
QuestionCurrency web services or other methods? Pin
udikantz20-Sep-07 7:56
udikantz20-Sep-07 7:56 
AnswerRe: Currency web services or other methods? Pin
Ravi Bhavnani20-Sep-07 10:33
professionalRavi Bhavnani20-Sep-07 10:33 
GeneralRe: Currency web services or other methods? Pin
udikantz20-Sep-07 12:30
udikantz20-Sep-07 12:30 
GeneralRe: Currency web services or other methods? Pin
Ravi Bhavnani21-Sep-07 12:31
professionalRavi Bhavnani21-Sep-07 12:31 
QuestionSql filling question Pin
sajid.salim.khan20-Sep-07 7:49
sajid.salim.khan20-Sep-07 7:49 
AnswerRe: Sql filling question Pin
Brady Kelly20-Sep-07 8:26
Brady Kelly20-Sep-07 8:26 

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.