How To have Combo with MultiColumn in Vb.Net

sjchin

Member
Joined
Mar 21, 2003
Messages
22
Hi guys, may i know any way make the combo in VB.Net contain multicolumns when user click on drop down? Is there any OCX or components can do it in VB.NET?
 
you mean so that theres text with another column next to it, or so that theres a drop down list of text?
eg:
text1 | text2
text3 | text4
or:
text1
text2
text3
text4
because for the drop down list i know thats a case of setting the comboboxs properties to "dropdownlist", then when you do something like....
Code:
ComboBox1.Items.Add(TextBox1.Text)Add to combobox
the list gets longer as you add the text to it.
 
my problem is the click on combo drop down, instead appear 1 columns, i want 2 or 3 columns.
Example :


Text1 Text 2 Test 3

Not
Text1
Text2
Text3

Beside this, as i know in VB.net contain Combo Version 2, may i know how to used it? Thanks
 
Ive never seen this feature in a ComboBox, but that doesnt mean it doesnt exist. I do know you can do this in a ListBox. Heres some VB6 code that works by setting the TabStops. I tried this on a ComboBox with no luck, but maybe it will spark something...

Code:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const LB_SETTABSTOPS As Long = &H192

Private Sub Form_Load()
    Dim Tabs(2) As Long
    Tabs(0) = 0
    Tabs(1) = 50
    Tabs(2) = 150
    SendMessage List1.hwnd, LB_SETTABSTOPS, CLng(UBound(Tabs)) + 1, Tabs(0)
    List1.AddItem "hello" & vbTab & "world" & vbTab & "dan"
    List1.AddItem "hello" & vbTab & "world" & vbTab & "dan"
    List1.AddItem "hello" & vbTab & "world" & vbTab & "dan"
End Sub

Note that the tabstop numbers (0, 50, 150) are always in Pixels (as far as I can tell).

-Nerseus
 
If you want you can use the Microsoft Forms 2.0 ComboBox. This type of combo box is similar to the one in Access that lets you have multiple columns.
 
No, you should not use the Forms 2.0 combobox. You are not allowed to distribute those controls with any application.
 
Back
Top