I have a table "Category".It is simply a table of users, where each are identified with a unique UserId and have a corresponding ParentId (pointing to their boss' UserId). If it's a top-level user, then the ParentId is set to 0. Can someone please help me figure out the best way to populate this list in a tree view?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
I guess you know how to read data from database so I skip that part.
An abstract version - you could read the employees from any source.
Some helper entities (you can do without them ofc - it is just easier/nicer to use this way):
The method used to populate a TreeView:
How to use it in your code:
Using the
BeginUpdate
/EndUpdate
methods will eliminate the "blinking" of your GUI.Just posted something similar on another post: Adding child nodes to tree view based on single database table with parent/child links
If you mean WinForms treeview I would do something like this (error checking skipped):