Windows Develop Bookmark and Share   
 index > Windows Forms General > Tree View Problem
 

Tree View Problem

Hi thi is my code xcan anybody tell me what i am doing wrong

i just need to bind this treeview to my list

    private void Form1_Load(object sender, EventArgs e)
        {
            List<int> hello = new List<int>();
            hello.Add(1);
            hello.Add(12);
            hello.Add(123);
            hello.Add(134);
            hello.Add(145);
            hello.Add(167);

            treeView1.Nodes = hello;

        }


connect2vishal  Saturday, April 18, 2009 9:27 AM
You can only add TreeNode objects. For example:

List<TreeNode> nodes = new List<TreeNode>();
nodes.Add(new TreeNode("1"));
nodes.Add(new TreeNode("12"));
treeView1.Nodes.AddRange(nodes.ToArray());

or:
List<int> hello = new List<int>();
hello.Add(1);
hello.Add(12);
foreach (int value in hello) {
treeView1.Nodes.Add(value.ToString());
}

Hans Passant.
nobugz  Saturday, April 18, 2009 1:10 PM
List<int> hello = new List<int>();
hello.Add(1);
hello.Add(12);
foreach (int value in hello) {
treeView1.Nodes.Add(value.ToString());
}

instead of adding i need to update it probably 1st become 7th or some data value will also change ;
connect2vishal  Saturday, April 18, 2009 1:59 PM
What?
Hans Passant.
nobugz  Saturday, April 18, 2009 2:08 PM
i mean the order can also change so every time its something like this is going to happens.......

i added first 3 nodes then
i changed 2 nodes values........ to something else
then i added 4 nodes between previous 2nd and 3rd node
this sort of suffling i am talking about.......
do u have ny idea how can i achieve this.......

the resolvetaskbar() fuction is the curcial point at this pointwhat i am doing is updating my list again and again.....
so i know i have todo something here........but what........ i cud nt get........
as i cant bind the treeview to a list with the help of data source.........

now can you help me.........

overall/......... how can i first aad nodes to tree view then clear them all and then again i have to add the same updated list....

or if you can sugest me some other good approach............

thanx in advance.........
connect2vishal  Saturday, April 18, 2009 7:42 PM
I have no suffling idea what a resolvetaskbar() function is and what it has to do with TreeView. Explain your question to a buddy. Once he gets it, ask him to type the question.
Hans Passant.
nobugz  Saturday, April 18, 2009 9:20 PM

actually...... i need to do few things if you people can understand my problem

1. i made a calss Task bar it has sme proprties........ that is a extending control.

2. i have a main application where i am going to use this control... ITs a kinda control that makes some bar graph on the basis of the data i have in object of TASKBAR class..........
and the issue is its a heirarical data.......

so in main aaplication i made a list of type task bar.........

now i just want to update this list into a tree view.....

the REsolveTaskbar() is a fucntion which keep refreshing my control....... even if u change somthing .....

so is my question is clea now...........
then i can expect my answe......


so at last i need the solution for same question i need to bind a list to tree view........
and dat is going to chnage like a sensex board..... at real time...... and the tree view need to be updated all the time.......

connect2vishal  Sunday, April 19, 2009 5:20 AM
pleaze help me out.........
connect2vishal  Monday, April 20, 2009 11:48 AM
i mean the order can also change so every time its something like this is going to happens.......

i added first 3 nodes then
i changed 2 nodes values........ to something else
then i added 4 nodes between previous 2nd and 3rd node
this sort of suffling i am talking about.......
do u have ny idea how can i achieve this.......

Did you want to know how to add the 4th node between the 2nd and 3rd node? It doesn't matter whether you change the value of the 2nd node. You can invoke the Insert method of the Nodes collection to insert this 4th node in the specified location. Just like the following:

treeView1.Nodes.Insert(2, "4"); // This is used to add the 4th node between the 2nd and 3rd.


If I misunderstood you, please let me know.

Best regards,
Bruce Zhou



Please mark the replies as answers if they help and unmark if they don't.
Bruce.Zhou  Thursday, April 23, 2009 10:54 AM

You can use google to search for other answers

Custom Search

More Threads

• How do I know if my e.Graphic is a screen or printer?
• System.Web.Mail
• Problems getting printer status
• Inserting into SQL Server Image Type Columns
• Toolstrip problem with order of tool items
• WebBrowser control = wait for page load to complete in an Assembly
• binding the textbox to grid
• I want to access data from another Computer through internate.
• Draw round border?
• Form always on top