Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populate treeview dynamically based on login.....

Status
Not open for further replies.

atruhoo

Programmer
Joined
Jan 8, 2003
Messages
131
Location
US
Group looking to use treeview as main navigation tool for windows app and want treeview and its nodes to be populated based on users security roles in database. Pretty new to using treeviews and have been playing around some with limited success and was wondering if the gurus here had any suggestions/examples that may help me down the right path.

Thanks in advance.
 
I'm a big opponent of bound data, so other may take a different approach.

My first recomendation would be to build a recursive search function. That'll make populating it much easier.

In the DB each element you want on the tree view will need a text value (to be displayed), a unique identifier, the identifier of it's parent, and a layer.

when you bring back the datatable w/ the node information available to the person's security info, sort it assending by level (0 being node, 1+ being the number of levels of parent nodes). This way, as you loop through them, you wont try adding a child node to a parent node that doesn't exist.

loop through the data table and add the node to the parent node based off a recursive search for their parent node.

That's my format atleast

-Rick

----------------------

[monkey]I believe in killer coding ninja monkeys.[monkey]
 
There was a post a couple days ago for something similar to this. Check that one out.


Rick--the TreeView doesn't have complex databinding anyways.
 
RG - good to hear! If you want a way to do it threw binding though you can use the C1 Flex Grid in tree mode. Although I would HIGHLY recommend against it.

-Rick

----------------------

[monkey] I believe in killer coding ninja monkeys.[monkey]
 
The C1 Flex Grid can be turned into a TreeView? I've never used it.
 
Yeah, apparently there is an issue w/ the MS Tree View and focus, so to get arround it some of the developers here (befor my time and on other projects) used a C1 Flex Grid in Tree View mode. I haven't played with it myself, but it looks pretty handy. But I would still recommend not binding data to it.

-Rick

----------------------

[monkey] I believe in killer coding ninja monkeys.[monkey]
 
Sorry took a few days to reply but out of office and was trying to not think about work. Wanted to thank you both for your input.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top