473,664 Members | 3,028 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ValueMember proprety in ListControls

I have implemented a combobox and have set the DataSource to an ArrayList.

I next set the DisplayMember and ValueMember properties.

When I run the code the combobox will display the proper text set by
DisplayMember but it seems that the
ValueMember doesn't work correct because when I go to use the SelectValue
property it never displays the correct text in the combobox.

Here is an example of my code:

Initialize combobox (myComboBox):
this.DataSource = Providers;
this.DisplayMem ber = "FullName";
this.ValueMembe r = "ID";

Where Providers is an arraylist of provider structs that have "FullName" and
"ID" properties. FullName will return a string and ID will return an
integer (via get accessor).

Then in the initialization code of the dialog box the comobox box belongs to
I do:

myComoboBox.Sel ectedValue = 3 // for example

After setting the SelectedValue property the text in myComboBox is still the
first item in the ArrayList.

Can someone give me an idea why?
Thank you in advance,

Eric
Nov 16 '05 #1
0 1163

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

Similar topics

2
2015
by: Supa Hoopsa | last post by:
Working on a windows form, I am trying to bind a listbox to a dataset and want to set the displaymember & Valuemember properties of the listbox so that I can retrieve the selectedvalue from a selecteditem in the listbox. My code is very simple: lstReports.DataBindings.Clear() lstReports.DataSource = dsDataSet.Tables("Reports") lstReports.DisplayMember = "ReportDescription" lstReports.ValueMember = "ReportsKey"
1
5665
by: Tonya | last post by:
Hi! I have a CheckedListBox, bound to a DataSet using DisplayMember and ValueMember. I need to have the ValueMember of all checked items in run time. the only way to receive ValueMember is through the SelectedValue, which is not useful in my situation. what is the best way to have the collection of
1
11053
by: Jim Heavey | last post by:
If you have a comboBox which has it's DisplayMember and ValueMenber bound to a datatable. If I know the "ValueMember" value - is there a way for me to set the index of the control to correspond to that ValueMember without having to iterate over the values in the control to find the index of the matching value menber? There is a "FindString" method of the ComboBox which apparently iterates over the collection looking form a match on...
0
1136
by: Alpha | last post by:
I am getting the following Exception error message when I assign the listbox Value to a table column in dataset. The dataset gets the tables and value from SQL table. There is no error if I comment out the ValueMember assignment. There are several other combox using the same dataset but different tables and they're all fine with their Valuemember assignments. Can someone tell me what I'm doing wrong here? Thanks, Alpha ...
1
1284
by: geraldine hobley | last post by:
Hello, I wish to set the valuemember of a combobox to the value of a property in a class(projlist - see below). I wish to set the valuember of the combobox cmbstatus to the value of property "status" in the class Projlist) Below is how I bind the text field phone on form Myform to the property phone in class projlist, this works fine.
3
2146
by: Stefano | last post by:
I've a form windows with a lot of textbox controls. How can I do if I have to save all text proprety of this controls in an external file, to reload them in future?
1
1570
by: Bruce A. Julseth | last post by:
Sorry. The other post got sent before I was complete. Does the ValueMember property in the ComboBox work like the DisplayMember property. For example, if I set the properties: comboBox1.DataSource = dataSet1 comboBox1.DisplayMember ="Employees.LastName" comboBox1.ValueMember = "Employees.EmployeeID" If I select from the box a "LastName", I can retrive that selected name. How
5
2713
by: Spam Catcher | last post by:
Hello all, I can't seem to set the value member properly in code... I'm using a ComboBox in DropDownList mode: Private Class ApplicationsComboBoxItem Private _Name As String Private _Application As ApplicationWorker
5
34070
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
8348
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
8861
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
8549
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,...
0
8636
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
6187
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
5660
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();...
1
2764
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
2003
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1759
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.