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

C#

 
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 
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 
Yes, the code sample helped clarify things. I would change the Build function so that it takes a reference to the TreeView and also makes use of the AddRange call to add the nodes. It would end up looking something like this:
C#
public static void Build(ref TreeView treeView)
{
   TreeNode mainNode = new TreeNode("MainNode");
   List<TreeNode> childNodes = new List<TreeNode>();
   for (int i = 0; i <= 5000; i++)
   {
       TreeNode childNode = new TreeNode("ChildNode" + i.ToString());
       TreeNode subNode = new TreeNode("SubNode");
       childNode.Nodes.Add(subNode);
       childNodes.Add(childNode);
   }
   treeView.Nodes.AddRange(childNodes.ToArray());
}
Depending on how you are actually creating the sub nodes, you may also want to do something similar and use a List<TreeNode> and AddRange to populate the Nodes collection of the childNode object.

This should give you better performance.


Scott.

—In just two days, tomorrow will be yesterday.

[Forum Guidelines] [Articles] [Blog]

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 
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 

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.