Click to See Complete Forum and Search --> : Combo Box
tejasbj
February 6th, 2000, 11:46 PM
i want the combo box that i am using to display multile columns.
how do i do it.
i am using it for database progg.
reply asap.
Regards,
Tejas Jois
February 7th, 2000, 10:10 AM
combo boxes don't have a multi-column option, and how would you use it if they did? List boxes do. If that's what you were referring to then for a list box set lb.columns = n where n > 0 and as many columns as needed will be made to hold the data.
tejasbj
February 7th, 2000, 12:11 PM
i want the list box controls to refer to differnet columns.
i.e. the first column shld rfer to one field in the database,while the next column shld refer toanother field. how do i do this.??
Tejas Jois
Johnny101
February 7th, 2000, 04:37 PM
Without going to a third party control - this is the best you can do:
Use the Win32 API to set tab stops in a Visual Basic list box by creating these declarations and routine in a module:
public Const LB_SETTABSTOPS = &H192
Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(byval hwnd as Long, _
byval wMsg as Long, _
byval wParam as Long, _
lParam as Any)as Long
Sub SetListTabStops(iListHandle as Long)
' sets 2 tab stops in a list box at the 24th
' and 48th character
' iListHandle = the window handle of the list box
Dim iNumColumns as Long
Dim iListTabs(1) as Long
Dim Ret as Long
iNumColumns = 2
iListTabs(0) = 96 ' 96/4 = 24 characters
iListTabs(1) = 192 ' 192/4 = 48 characters
Ret = SendMessage(iListHandle, LB_SETTABSTOPS, iNumColumns, iListTabs(0))
End Sub
In your form, create a list box called lstMyListBox. Call this routine in the form load to set your tab stops:
Call SetListTabStops(lstMyListBox.hwnd)
Then add items to the list box using vbTab:
lstMyListBox.AddItem "Column 1 data" & vbTab & "Column 2 data"
You can adjust the number of columns and their width by change the values of iListTabs().
Hope this helps,
John
John Pirkey
MCSD
www.ShallowWaterSystems.com
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.