Click to See Complete Forum and Search --> : [2.0] Issue on sorting a treeview.
mar_zim
Aug 15th, 2006, 04:37 AM
I loaded hundreds of data in treeview w/ child nodes and I want it to be sorted but the problem occur when I used the sort() property of the treeview the child nodes get lost. Any one same issue with this?
btw Is it advisable to load a bunch of data in treeview for the sake of easy browsing or not?
My next option is just used combobox.
DNA7433
Aug 15th, 2006, 05:55 PM
If your going next attempt is with a combo box then wouldn't a list box be good enough instead of a tree view? And no, I've never heard of nodes disappearing when you call Sort(). How are you loading data into the treeview?
mar_zim
Aug 15th, 2006, 07:08 PM
Actually the data has a heirarchy that's why I used treeview. I just loop to populate my treeview. If you populate a treeview w/ a hundred's of data and call the sort property the child nodes disappear. I don't know maybe it's a bug or i'm the bug.:D
DNA7433
Aug 15th, 2006, 10:11 PM
Well I opened a brand new project and put a TreeView and Button on the form and here is the complete code I used:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace TreeViewTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
for (int i = 0; i < 20; i++)
{
TreeNode node1 = treeView1.Nodes.Add(i.ToString());
for (int j = 0; j < 10; j++)
{
TreeNode node2 = node1.Nodes.Add(j.ToString());
for (int k = 0; k < 3; k++)
{
node2.Nodes.Add(k.ToString());
}
}
}
}
private void button1_Click(object sender, EventArgs e)
{
treeView1.Sort();
}
}
}It loaded the tree correctly, and after I pressed the button it sorted everything and every single node was still there. So, what are the differences between this example and your project?
mar_zim
Aug 15th, 2006, 11:24 PM
Try to add up to 500 data in your nodes then call the sort property and tell me if its ok.
DNA7433
Aug 16th, 2006, 06:06 PM
I think you should create your own separate test projects and run your own tests.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.