Connecting Tech Pros Worldwide Forums | Help | Site Map

mulitcolumn listbox and datasource property question

David Webster
Guest
 
Posts: n/a
#1: Nov 21 '05
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.

Ken Tucker [MVP]
Guest
 
Posts: n/a
#2: Nov 21 '05

re: mulitcolumn listbox and datasource property question


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

--------------------
"David Webster" <David Webster@discussions.microsoft.com> wrote in message
news:702563FB-11E4-411B-B010-E87E201BE974@microsoft.com...
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.


Ken Tucker [MVP]
Guest
 
Posts: n/a
#3: Nov 21 '05

re: mulitcolumn listbox and datasource property question


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

--------------------
"David Webster" <David Webster@discussions.microsoft.com> wrote in message
news:702563FB-11E4-411B-B010-E87E201BE974@microsoft.com...
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.


Cor Ligthert
Guest
 
Posts: n/a
#4: Nov 21 '05

re: mulitcolumn listbox and datasource property question


David,

The multicolumn property in a listbox makes it from a horizontal one a
vertical one.

http://msdn.microsoft.com/library/de...olumntopic.asp

When you want more columns you will need something as a datagrid when you
want to access it with a datasource, a listview without that or create a
vertical multicolumn listbox yourself.

I hope this helps something?

Cor


Cor Ligthert
Guest
 
Posts: n/a
#5: Nov 21 '05

re: mulitcolumn listbox and datasource property question


David,

The multicolumn property in a listbox makes it from a horizontal one a
vertical one.

http://msdn.microsoft.com/library/de...olumntopic.asp

When you want more columns you will need something as a datagrid when you
want to access it with a datasource, a listview without that or create a
vertical multicolumn listbox yourself.

I hope this helps something?

Cor


Closed Thread


Similar Visual Basic .NET bytes