468,242 Members | 1,710 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,242 developers. It's quick & easy.

Help with listbox displaymember...

Hello All,
I know this is a re-post, but I didn't get any bites on my last post. So here goes again:

I have a listbox which is bound to a datatable. I have set the displaymember and valuemember and all works well:
the user dbl clicks an item in the list box, I use the valuemember to retrieve some values from the db. However, I would like
a label to display the displaymember value that was selected by the user. I am assuming this is a datarow(?).
How does one do this? Below is my code for populating the listbox:
Dim dtChgDept As New DataTable
daChgDept.Fill(dtChgDept)
lstChgDept.ValueMember = "dept_id"
lstChgDept.DisplayMember = "dept_name"
lstChgDept.DataSource = dtChgDept
How can I display the text value of the displaymember "dept_name" on a label??

Thanks in advance!

Frankie
--
----------------------------------------------
Posted with NewsLeecher v3.5 Beta 1
* Binary Usenet Leeching Made Easy
* http://www.newsleecher.com/?usenet
----------------------------------------------

May 19 '06 #1
2 5064
Frankie,

The listbox's Text property should contain the displaymember of the selected
item.

So just assign the listbox's Text property to the label's Text property.

Kerry Moorman
"Frank" wrote:
Hello All,
I know this is a re-post, but I didn't get any bites on my last post. So here goes again:

I have a listbox which is bound to a datatable. I have set the displaymember and valuemember and all works well:
the user dbl clicks an item in the list box, I use the valuemember to retrieve some values from the db. However, I would like
a label to display the displaymember value that was selected by the user. I am assuming this is a datarow(?).
How does one do this? Below is my code for populating the listbox:
Dim dtChgDept As New DataTable
daChgDept.Fill(dtChgDept)
lstChgDept.ValueMember = "dept_id"
lstChgDept.DisplayMember = "dept_name"
lstChgDept.DataSource = dtChgDept
How can I display the text value of the displaymember "dept_name" on a label??

Thanks in advance!

Frankie
--
----------------------------------------------
Posted with NewsLeecher v3.5 Beta 1
* Binary Usenet Leeching Made Easy
* http://www.newsleecher.com/?usenet
----------------------------------------------

May 19 '06 #2
That did the trick!

Thanks!!

Frankie!!
--
----------------------------------------------
Posted with NewsLeecher v3.5 Beta 1
* Binary Usenet Leeching Made Easy
* http://www.newsleecher.com/?usenet
----------------------------------------------

May 19 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Irwin M. Fletcher | last post: by
7 posts views Thread by Dave | last post: by
reply views Thread by frank | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.