Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Binding treeview to an array

Binding treeview to an array

Scheduled Pinned Locked Moved C#
csharpwpfwcfdata-structuresquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    LordZoster
    wrote on last edited by
    #1

    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

    T 1 Reply Last reply
    0
    • L LordZoster

      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

      T Offline
      T Offline
      The Man from U N C L E
      wrote on last edited by
      #2

      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]

      L 1 Reply Last reply
      0
      • T The Man from U N C L E

        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]

        L Offline
        L Offline
        LordZoster
        wrote on last edited by
        #3

        thanks.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups