mulitcolumn listbox and datasource property question

G

Guest

I have the following bit of code (which works fine):

Dim Customer As New CCustomer
mFrmOrder.lstCustID.DataSource =
Customer.getCustomers.Tables("data")
mFrmOrder.lstCustID.DisplayMember = "surname"
mFrmOrder.lstCustID.ValueMember = "custID"
mFrmOrder.lstCustID.Refresh()
mFrmOrder.lstCustID.ClearSelected()
Customer = Nothing

My customer dataset ("Customer.getCustomers.Tables("data")") has 8 columns ,
I have set the the "custID" column in my dataset to equal the valuemember
property of the listbox and the "surname" to equal the Display member
property.

However, I want to change the listbox to DISPLAY two columns so the
displaymember for column 1 will equal "firstName" and then the displaymember
for column2 will be "surname". The valuemember stays the same with "custID".
How do I do this ?!?!.

All I now is that I need to add the code
"lstCustID.multicolumns = true" at the start of my code chunk...

Please advise,

Many thanks.
 
K

Ken Tucker [MVP]

Hi,

Add a new calculated column to your dataset. Use that column as the
displaymember in the listbox.

Dim dc As DataColumn

'

' Add a new column in clients table which

' is full name.

dc = New DataColumn("Name")

dc.DataType = System.Type.GetType("System.String")

dc.Expression = "LastName + ', ' + FirstName"

dsClient.Tables(0).Columns.Add(dc)



Ken

--------------------
I have the following bit of code (which works fine):

Dim Customer As New CCustomer
mFrmOrder.lstCustID.DataSource =
Customer.getCustomers.Tables("data")
mFrmOrder.lstCustID.DisplayMember = "surname"
mFrmOrder.lstCustID.ValueMember = "custID"
mFrmOrder.lstCustID.Refresh()
mFrmOrder.lstCustID.ClearSelected()
Customer = Nothing

My customer dataset ("Customer.getCustomers.Tables("data")") has 8 columns ,
I have set the the "custID" column in my dataset to equal the valuemember
property of the listbox and the "surname" to equal the Display member
property.

However, I want to change the listbox to DISPLAY two columns so the
displaymember for column 1 will equal "firstName" and then the displaymember
for column2 will be "surname". The valuemember stays the same with
"custID".
How do I do this ?!?!.

All I now is that I need to add the code
"lstCustID.multicolumns = true" at the start of my code chunk...

Please advise,

Many thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top