473,400 Members | 2,145 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,400 software developers and data experts.

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 5245
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Alex Stevens | last post by:
I'd already posted this in microsoft.public.dotnet.framework.windowsforms and microsoft.public.dotnet.framework.windowsforms.controls to no avail so apologies for the cross-posting. Hi, I'm...
1
by: Irwin M. Fletcher | last post by:
ListBox DataSource DisplayMember Property Problems in C# I have a (single select) listbox with data and when I click on the list I can't get the right text selected. My listbox is setup...
1
by: Zoury | last post by:
Hi there! :O) I have a WebService that contains the following struct definition. this struct is defined right after the WebService class, ie : //*** namespace mynamespace { public class...
4
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 =...
5
by: Dave | last post by:
Hi all, Is it possible to populate a listbox from a hashtable (complexbind) where the ValueMember of the listbox maps to the "key" member of the hashtable AND the DisplayMember of the listbox maps...
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...
16
by: Allen | last post by:
I have a class that returns an arraylist. How do I fill a list box from what is returned? It returns customers which is a arraylist but I cant seem to get the stuff to fill a list box. I just...
0
by: frank | last post by:
Hello, 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...
5
by: =?Utf-8?B?QmVu?= | last post by:
How would you add an item with its DisplayMember and ValueMember without binding to a datatable or dataview like: listbox.DisplayMember = "name"; listbox.ValueMember = "recid"; listbox.DataSource...
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
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.