dotnet treeview; expanding items via code

dotnet treeview; expanding items via code

Anonymous
Not applicable
464 Views
7 Replies
Message 1 of 8

dotnet treeview; expanding items via code

Anonymous
Not applicable
yay another dotnet question!

so I have a treeview set up, I want to expand some of the items via code when the treeview is populated.
i can't set it using .IsExpanded, since that is read-only... and i don't want to use "TheTreeView.ExpandAll()" since that will expand everything, which I do not want to do.

so any ideas?

thanks much!
0 Likes
465 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
ok, i have a way to do this but it seems a little hackey...

so I have a function to populate my treeview. I set up all of my items that I want expanded, I then use "TheTreeView.ExpandAll()"
AFTER that I add the items that i want non-expanded

this does work for my specific case, but i can see where it would quickly fall apart.
0 Likes
Message 3 of 8

Anonymous
Not applicable
You have to use methods of the actual nodes. The TreeNode dotNet class has an "Expand()" method (which internally would set the isExpanded property of the node).

ie :
myTreeView.Nodes.item.expand()


G
0 Likes
Message 4 of 8

Anonymous
Not applicable
ahhh!
that works for me. Any tips on where to look for more info on dotnet methods?
thanks much..
0 Likes
Message 5 of 8

Anonymous
Not applicable
I usually have a copy of visual studio open with a temp project that i can drop controls into to help me work this stuff out. Visual studio has auto complete for methods and properties etc so I usually just use that instead of a reference. Sometimes I also use the designer to setup properties etc on a control and then look at the code it generates and try and convert that to maxscript.

You can also use MSDN, for example this is the page that has all the members listed for a dotnet treeview control:
http://msdn.microsoft.com/en-us/library/system.windows.forms.treeview_members.aspx



G
0 Likes
Message 6 of 8

Anonymous
Not applicable
I have been writing maxscripts for a while now.... but never taken the plunge into visual studio... thats on the horizon for me 🙂
thanks for the help!
0 Likes
Message 7 of 8

Anonymous
Not applicable
You can also see a control's associated methods by doing:
showMethods control
0 Likes
Message 8 of 8

Anonymous
Not applicable
Oh, and I forgot Reflector:
http://www.aisto.com/roeder/dotnet/

G
0 Likes