C# XML ListBox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • EinToR
    New Member
    • May 2008
    • 20

    C# XML ListBox

    I'm trying to make a series of listboxes that filter the next listbox.

    Ex.:
    Listbox01: Toyota, Hundai
    Listbox02 (Toyota selected): Supra, Corola
    Listbox03: (Supra selected): Red, Black

    The DataSource is an XML file simnilar to this:

    Code:
    <items>
      <item name="Toyota">
        <item name="Supra">
          <item name="Red"></item>
          <item name="Black"></item>
        </item>
        <item name="Corola">
          <item name="Red"></item>
          <item name="Green"></item>
        </item>
      </item>
      <item name="Hundai">
        <item name="Elantra">
          <item name="Black"></item>
          <item name="Blue"></item>
        </item>
      </item>
    </items>
    I know how to create the listboxes but can't figure out how to query the XML to get what I want. It has to be done in C# 2.0...
  • cloud255
    Recognized Expert Contributor
    • Jun 2008
    • 427

    #2
    I would make an object which holds a collection of models and also a collection of colours, or if colours are model specific i would put the colour collection in inside te model object.

    thus fill the object using the parent/child relationship of the XML. you could make an array of these objects and insert that a as the datasource for your first text box, then fill the other text boxes with the data in the object, not directly from the XML file.

    good luck

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      I'm not sure if you are developing ASP.NET or a desktop application. If you are developing an ASP.NET application there is a CascadingDropDo wn control that CodePlex has made freely available to developers. It's not ListBoxes but I think it would accomplish what you would like to do.

      -Frinny

      Comment

      Working...