|
-
Feb 6th, 2016, 11:16 AM
#1
Thread Starter
Lively Member
Database one column to ListBox?
Hi,
From my database I have managed to fire a query so select just one column of the name of the details I want.
It shows up fine in the data grid but I want to use ListBox instead of DataGrid.
How can I achieve this?
Here is my code:

This is the result:

Please let me know what I can do.
-
Feb 6th, 2016, 01:37 PM
#2
Re: Database one column to ListBox?
Start by posting code as text wrapped in code tags...
You need to set the DisplayMember of the list box to the data table column name.
Code:
ListBox1.DisplayMember="CName"
I can't remember whether the DisplayMember should be set before or after the data source is set, but I do believe it matters.
Process control doesn't give you good quality, it gives you consistent quality.
Good quality comes from consistently doing the right things.
Vague general questions have vague general answers. A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.
______________________________ Last edited by kebo : Now. Reason: superfluous typo's
-
Feb 6th, 2016, 02:13 PM
#3
Re: Database one column to ListBox?
DisplayMember and ValueMember both need to be set BEFORE the DataSource ... Doesn't matter which order Display/Value member gets set, they just need to be set before the datasource.
-tg
-
Feb 7th, 2016, 12:45 AM
#4
Thread Starter
Lively Member
Re: Database one column to ListBox?
 Originally Posted by kebo
Start by posting code as text wrapped in code tags...
You need to set the DisplayMember of the list box to the data table column name.
Code:
ListBox1.DisplayMember="CName"
I can't remember whether the DisplayMember should be set before or after the data source is set, but I do believe it matters.
 Originally Posted by techgnome
DisplayMember and ValueMember both need to be set BEFORE the DataSource ... Doesn't matter which order Display/Value member gets set, they just need to be set before the datasource.
-tg
Thanks guys, that worked! Thank you so much! +rep.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|