Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multicolumn listbox 1

Status
Not open for further replies.

hysaccess

Programmer
May 27, 2003
12
AU
I'm back again,

I am having trouble adding multicoloumns to a listbox by code ... I can only add items to the first coloumn ...

Help ??

The values are not in a database it is programmatically made
 
How are you trying to assign values to the columns now?

Method1 (Using a comma delimiter)
MyListbox = "FirstColumnRow1,SecondColumnRow1;FistColumnRow2,SecondColumnRow2"

Method2 (Using SQL to fill the listbox)
strSQL = "SELECT myTable.FirstColumn, myTable.SecondColumn FROM myTable;"
myListbox.RecordSource = strSQL
myListbox.Refresh

These methods work in Access but not in VB, which uses an AddItem method to add listbox items.

Important: You must set the ColumnCount property to the number of columns you want to include on the listbox and the ColumnWidths property to the width of each of the columns to be included. The code below will set up 4 columns with only the first column (0) to be displayed in a two inch width display. The bound column that will be loaded into the database is column 0.

myListbox.ColumnCount = 4
myListbox..ColumnWidths = "2,0,0,0"
myListbox.BoundColumn = 0




---------------------
scking@arinc.com
---------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top