Binding treeview to an array
-
Hallo I need to display in a TreeView an array with three fields: DisplayName, Value and Level (0-1) which determines if it is a child or a node. Is there any way in .Net 2.0+ to bind a treeview to an array in the fashion of the ListBox, using DataSource, DisplayMember and ValueMember? (maybe the Level could be managed in a separate way) I found a code snippet using these properties but it doesn't work, it seems dated back to earlier .Net, 1.1 or 1.0 Or should I go straight using an iteration that loops through the array? Thanks in advance
-
Hallo I need to display in a TreeView an array with three fields: DisplayName, Value and Level (0-1) which determines if it is a child or a node. Is there any way in .Net 2.0+ to bind a treeview to an array in the fashion of the ListBox, using DataSource, DisplayMember and ValueMember? (maybe the Level could be managed in a separate way) I found a code snippet using these properties but it doesn't work, it seems dated back to earlier .Net, 1.1 or 1.0 Or should I go straight using an iteration that loops through the array? Thanks in advance
The .Net treeview does not natively support binding like this. While you should indeed iterate though the array creating the appropriate nodes it would probably be best to subclass the treeview and add your own binding code so you can reuse it. Unfortunately the binding code would have to iterate through the datasource, and the structure would have to be fixed.
If you have knowledge, let others light their candles at it. Margaret Fuller (1810 - 1850) [My Articles] [My Website]
-
The .Net treeview does not natively support binding like this. While you should indeed iterate though the array creating the appropriate nodes it would probably be best to subclass the treeview and add your own binding code so you can reuse it. Unfortunately the binding code would have to iterate through the datasource, and the structure would have to be fixed.
If you have knowledge, let others light their candles at it. Margaret Fuller (1810 - 1850) [My Articles] [My Website]
thanks.