How to display the selected items in combobox with 2 columns?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • xabc
    New Member
    • Jun 2010
    • 1

    How to display the selected items in combobox with 2 columns?

    Hi,

    I have this simple code which would display 2 columns of data in a combobox. However, when I click a selection only the data in the first column is displayed. I there a way to display the second column as well? Example, when I select "1 String 1" from the dropdown list I want to see "1 String 1" in the combobox value.

    Code:
    Sub FillData()
    Dim x(1, 1) As Variant
    
    x(0, 0) = 1
    x(0, 1) = "String 1"
    x(1, 0) = 2
    x(1, 1) = "String 2"
    
    Combobox1.ColumnCount = 2
    Combobox1.ColumnWidths = "15, 100"
    Combobox1.List = x
    End Sub
  • QVeen72
    Recognized Expert Top Contributor
    • Oct 2006
    • 1445

    #2
    Hi,

    Try this :

    [code=vb]
    Text1.Text = Combo1.List(Com bo1.ListIndex, 0)
    Text2.Text = Combo1.List(Com bo1.ListIndex, 1)
    [/code]

    Regards
    Veena

    Comment

    Working...