473,769 Members | 4,283 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ListBox DataSource DisplayMember Property Problems

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.ValueM ember = "TypeID";
listBox1.Displa yMember = "Name";

I am able to get the "TypeID" (ValueMember) when I click on
the items.
I do that like this...
int intTest;
intTest = System.Int32.Pa rse(listBox1.Se lectedValue.ToS tring());

But I can't get the text (DisplayMember) .
I have used these two ways, but...
string strDispMem;
strDispMem = listBox1.Items[index].ToString();
// the above returns... "System.Data.Da taRowView"

or
strDispMem = listBox1.Text;
// The above repeats first selection the user clicks on.
Any ideas???
Thanks... Irwin
Nov 15 '05 #1
1 15167
Anyone with any ideas on how to solve this?
Thanks... Irwin.

In************* *******@hotmail .com (Irwin M. Fletcher) wrote in message news:<9a******* *************** ****@posting.go ogle.com>...
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.ValueM ember = "TypeID";
listBox1.Displa yMember = "Name";

I am able to get the "TypeID" (ValueMember) when I click on
the items.
I do that like this...
int intTest;
intTest = System.Int32.Pa rse(listBox1.Se lectedValue.ToS tring());

But I can't get the text (DisplayMember) .
I have used these two ways, but...
string strDispMem;
strDispMem = listBox1.Items[index].ToString();
// the above returns... "System.Data.Da taRowView"

or
strDispMem = listBox1.Text;
// The above repeats first selection the user clicks on.
Any ideas???
Thanks... Irwin

Nov 15 '05 #2

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

Similar topics

5
540
by: Brian | last post by:
Hi, All, I'm using MS.net 2003 and using a windows.forms.listbox control for my window application but I don't know why the Horizontal Scrollbar could NOT be shown even if I set HorizontalScrollbar = true. The text info in listbox already beyond its right edge. How can I see the hidden part info in listbox? here is a part of codes. ListBox.ValueMember = XX ListBox.DisplayMember = XXXX
3
9064
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 set the "DataSource", "DisplayMember", and "ValueMember" properties of the ListBox correctly like below: lbTechnician.DataSource = TechnicianDataSet.Tables;
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
11
8556
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 the array list again to refresh. Click on an item in the list, and an Indexing error comes up. (in non-user code, it is trying to get an element from the array that is greater than the number of items in the array.) To reproduce:
0
1689
by: Dave | last post by:
Hi all, I have a listbox that is complex bound by an arraylist. The problem is that when I delete an object from the arraylist, the listbox does not reflect those changes. I tried refreshing the listbox with no luck and, because it is already bound, I can't just delete the item directly from the listbox without an error (because it already has a datasource, you are not allowed to delete/add anything to the listbox directly). The...
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:
1
2780
by: A. Spiehler | last post by:
I'm trying to fill a listBox control with string members from an array of objects. I think using data binding is supposed to be the easiest way to do this. I've never used data binding before and am having trouble getting it to do anything. The relevant code is below, followed by a better explanation of what I'm trying to do. // pseudocode start public delegate string StepMethod();
2
5256
by: frank | last post by:
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...
2
5544
by: =?Utf-8?B?U3RlcGhlbiBSaXRjaGll?= | last post by:
Hi NET1.1 / Winforms I have a listbox that I am binding to a table via the DataSource property. However I want to be able to programmatically select values in this listbox so I am using the code below... With lstJobTypes .DataSource = BusinessRules.Common.JobTypes.All(True)
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...
0
10036
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9855
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
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
5444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3952
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
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.