473,385 Members | 1,798 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,385 software developers and data experts.

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.DisplayMember = "FullName";
this.ValueMember = "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.SelectedValue = 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 1147

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

Similar topics

2
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...
1
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...
1
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...
0
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...
1
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...
3
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
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: ...
5
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...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.