Do you guys have a tutorial or some sort of guide on programatically setting up columns with the Ultratree? I have 70% of it figured out I just need to put it all together.
Basically, I have a set of folders that have items, just like Explorer. I want to have 2 property columns, date added and Item Type. Issue is Item Type comes from another database entierely (only used when we interface into an accounting system). Plus all the items in the folders don't exist in the same table so I build it through code. (which works very well).
If there is not tutorial, I just need a few lines of code that explains how to add a node programatically with these columns. I have created a column set, and have added three columns.
SO now, I have something like
ut.Nodes.Add(fromSQL.ID, fromSQLName)
How can I get fromSQLName into my Column Item, then reference this item so that I can populate date added and Item TYpe.
Thanks.
The Nodes.Add method returns an UltraTreeNode. You can store this and then set the values of the cells on the node.
node.Cells["Item"].Value = whateverValueIWant;
This will only work if the ColumnSet has already been applied to the tree, of course. Otherwise the node won't know what it's columns are.
That worked out but let me ask two more brief questions.
1) So I am tried to set the image , t.Cells["Item"].Appearence.Image = copyfrom.LeftImages[0];
And , it did not work, so I tried to cast LeftImages[0] to Bitmap and it gave me an error about casting to Int32. So what I figured out I guess is that LeftImages[0] is storing the Index # of the imagelist attached to that tree. So what I ended up doing was :
worknode.Cells[0].Appearance.Image = ilProject.Images[(
Int32)t.LeftImages[0]];
You may (or may not) recall a post I had about testing for what image a node had, and I was having all those issues, so now I understand what I can do to figure out what image I have by comparing the index to the imagelist.
2) If i do this:
UltraTreeNode worknode;
worknode = Tree.Nodes.Add(tn.Clone);
the above line returns an INT...vs. the object reference. Why?