Combo Box

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kevin Lippiatt

    #1

    Combo Box

    I'm confused as to how to use the combo box in vb.net. I want a combo box to
    contain items that have both a display string and a value string. The display
    string gets displayed in the drop down and the value string is the key of the
    item
    In vb6 i could add these items to the combobox and then use
    combobox.select edvalue to set or get the selected item. How do i do this in
    vb.net?
    It seems I can only enter one string?
    Also how do I stop users typing into the combo box? i.e. force them to
    select an existing value in the dropdown and not type one in.
  • Cor Ligthert

    #2
    Re: Combo Box

    Kevin,

    Your first question that means that you have to create an array or what I
    prefer a datatable.

    Than you can set as the datasource of the combobox and use both the
    displaymember and the valuemember. The last gives when selected the
    selectedvalue.

    Your second question means that you have to set the combobox style to
    dropdownlist.

    I hope this helps,

    Cor


    Comment

    • Kevin Lippiatt

      #3
      Re: Combo Box

      thank you. I don't really understand how to go about using an array with the
      combobox, but the datatable method seems promising.
      for interests sake how would u implement using an array? a multidimensiona l
      array? what would you set the displaymember and valuemember to? with a
      datatable u would use the column name but how do u reference the dimesions of
      the array?

      kevin

      "Cor Ligthert" wrote:
      [color=blue]
      > Kevin,
      >
      > Your first question that means that you have to create an array or what I
      > prefer a datatable.
      >
      > Than you can set as the datasource of the combobox and use both the
      > displaymember and the valuemember. The last gives when selected the
      > selectedvalue.
      >
      > Your second question means that you have to set the combobox style to
      > dropdownlist.
      >
      > I hope this helps,
      >
      > Cor
      >
      >
      >[/color]

      Comment

      • Cor Ligthert

        #4
        Re: Combo Box

        Kevin,

        You can add objects to an arraylist and use the properties of those.

        I seldom did it, you have a lot to cast when you do it, I am lazy enough to
        use the datatable.

        Cor


        Comment

        Working...