473,769 Members | 2,515 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Valu eMember = "dept_id"
lstChgDept.Disp layMember = "dept_name"
lstChgDept.Data Source = 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 5256
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.Valu eMember = "dept_id"
lstChgDept.Disp layMember = "dept_name"
lstChgDept.Data Source = 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
2419
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 writing a usercontrol which displays the typical two listboxes and the ability to move items from one to the other. The listboxes are populated with my custom objects (SwapItem), which simply
1
15167
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 using the DataSource property. I set my ValueMember and DisplayMember listBox1.ValueMember = "TypeID";
1
1939
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 MyWebService : WebService {// code here..} public struct Record {
4
6534
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 = "surname" mFrmOrder.lstCustID.ValueMember = "custID" mFrmOrder.lstCustID.Refresh() mFrmOrder.lstCustID.ClearSelected() Customer = Nothing
5
7844
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 to the "value" member of the hashtable? I found that it is impossible to use a hashtable as a listbox datasource directly (from trial and error) and tried DirectCast-ing to an arraylist without any success. Before I spend anymore time in vain...
7
4539
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 ASP.Net stuff when I need a Windows Form control. I've seen dual listbox populators in countless Windows applications, and have seen them run very fast, so I figured this would be extremely popular. Here's how it should work:
16
2011
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 learning and really need some help bad. Public Shared Function GetAll() As ArrayList Dim dsCustomer As New DataSet() Dim sqlQuery As String = "SELECT Name, Address, PhoneNo " & _ "FROM CustomerTable" Try
0
1144
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 retrieve some values. 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...
5
34091
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 = dt; listbox.Items.Add(name) can only add the DisplayMember. Thanks,
0
9422
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10208
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9987
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7404
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5294
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3558
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2812
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.