473,386 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

mulitcolumn listbox and datasource property question

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.
Nov 21 '05 #1
4 6491
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 We*****@discussions.microsoft.com> wrote in message
news:70**********************************@microsof t.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.
Nov 21 '05 #2
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 We*****@discussions.microsoft.com> wrote in message
news:70**********************************@microsof t.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.
Nov 21 '05 #3
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
Nov 21 '05 #4
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
Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jason | last post by:
Here is an odd issue. I am trying to shed some light on why this is causing a problem. I have an ArrayList. I am binding it to a ListBox control with has its Sort property set to True. If the...
3
by: Prasad | last post by:
Hey All, I am having a little trouble with the ListBox's Items collection property. I am populating the ListBox with data contained in an SQL table using SQLDataAdapter and DataSet. I have...
4
by: dtblankenship | last post by:
Hello everyone, I know this question has been asked many times in the forums, and after spending a few days reading, I am still confused as to the answer. I have a ListBox (lstBox),...
0
by: David J | last post by:
Hi, I am strugling with the propertygrid and a listbox. I am using the universaldropdowneditor from the codeproject (code below). However I am populating the listbox via a datasource. The problem...
3
by: joe | last post by:
I actually have 2 questions: 1) Is databinding the fastest way to load a listbox from sqlserver? speed is crucial and I want to make sure i'm populating it the fastest way i can 2) Also,...
0
by: David Webster | last post by:
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 =...
11
by: Zorpiedoman | last post by:
The problem is this: I have a list box. I set an array list as the datasource. I remove an item from the array list. I set the listbox datasource to nothing. I set the listbox datasource to...
7
by: Dave | last post by:
Hi all, After unsuccessfully trying to make my own dual listbox control out of arraylists, I decided to look for a 3rd party control. I've looked for over a week now and can't find anything but...
3
by: caracolito1975 | last post by:
Hi to every one!!!! For some time now I'm programing in .NET and I have a question in using ListBox I need to databind a collection to a ListBox. My code is something like this: using...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.