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. Windows Forms
  4. Problem binding arraylist to combobox

Problem binding arraylist to combobox

Scheduled Pinned Locked Moved Windows Forms
wpfwcfhelpquestion
2 Posts 2 Posters 2 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.
  • N Offline
    N Offline
    Nigel Mackay
    wrote on last edited by
    #1

    private struct modelStruct
    {
    public string theModel;
    public int theModelID;
    }
    private modelStruct thisModelStruct;
    private ArrayList availableModels = new ArrayList();

    I add some items to the arraylist. Then I want

    cboModel.DataSource = availableModels;
    cboModel.DisplayMember = "ModelID";
    cboModel.ValueMember = "theModelID";

    But I need to do some casting or content exctraction, but where and how? For DisplayMember the combobox shows "ToolHistory.History+modelStruct". I have tried cboModel.DisplayMember = thisModelStruct.theModel; but it makes no difference.

    L 1 Reply Last reply
    0
    • N Nigel Mackay

      private struct modelStruct
      {
      public string theModel;
      public int theModelID;
      }
      private modelStruct thisModelStruct;
      private ArrayList availableModels = new ArrayList();

      I add some items to the arraylist. Then I want

      cboModel.DataSource = availableModels;
      cboModel.DisplayMember = "ModelID";
      cboModel.ValueMember = "theModelID";

      But I need to do some casting or content exctraction, but where and how? For DisplayMember the combobox shows "ToolHistory.History+modelStruct". I have tried cboModel.DisplayMember = thisModelStruct.theModel; but it makes no difference.

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      AFAIK your data provider must have properties, not fields, of the specified name(s) for data binding to work. :)

      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


      I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.
      [The QA section does it automatically now, I hope we soon get it on regular forums as well]


      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