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

Problem with Display/Value member of combo box

Having problems with combo box Display Member and Value Member.

Using a typed dataset I have the following:
private void frmMain_Load(object sender, EventArgs e)
{
cmbxPayee.DisplayMember = dataSet.Payee.P_NameColumn.ToString();
cmbxPayee.ValueMember = dataSet.Payee.P_IdColumn.ToString();
cmbxPayee.DataSource = dataSet.Payee;
}

The combo box is being correctly populated with payee names.

Later I do:

private void cmbxPayee_DisplayMemberChanged(object sender, EventArgs
e)
{

string thePayeeId = cmbxPayee.ValueMember.ToString();
MessageBox.Show(thePayeeId);
}

What is showing in the messageBox is the name of the column (P_Id) not the
value of the column (e.g. "D").

Have I correctly initialised the variable in my frmMain_Load method, and if
so, why is the value of the column not being shown?

Thanks
Oct 31 '08 #1
2 4482
Hi Paolo,

"Paolo" wrote:
private void cmbxPayee_DisplayMemberChanged(object sender, EventArgs
e)
{

string thePayeeId = cmbxPayee.ValueMember.ToString();
MessageBox.Show(thePayeeId);
}
You use the wrong event.
Use SelectedValueChanged and get the id from
cmbxPayee.SelectedValue.ToString();

Walter
Oct 31 '08 #2
Walter: thank you. That has worked perfectly.

"Walter Frank" wrote:
Hi Paolo,

"Paolo" wrote:
private void cmbxPayee_DisplayMemberChanged(object sender, EventArgs
e)
{

string thePayeeId = cmbxPayee.ValueMember.ToString();
MessageBox.Show(thePayeeId);
}

You use the wrong event.
Use SelectedValueChanged and get the id from
cmbxPayee.SelectedValue.ToString();

Walter
Oct 31 '08 #3

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

Similar topics

3
by: Billy Jacobs | last post by:
I have created a DataGridColumnDatePicker Component so that I can put a datetimepicker control in my datagrid. It almost works. When I put my mouse in the cell it changes to a datetimepicker...
4
by: Andy | last post by:
Hopefully this is a simple one to answer .... Designed a form with 2 combo boxes (surname & member). For some strange reason they both show Surnames although I think im pointing to the correct...
6
by: Harshil | last post by:
I am developing an application in vb.net and oracle as my database. my goal is to display the county names (display member) to the user while store county id (value member) in the combo box. when I...
6
by: Ron L | last post by:
I have a dataset whose source is a SQL 2k stored procedure that I am trying to display in a datagrid. This datasource has 4 columns that I am interested in here, a text column and 3 value columns...
6
by: visionstate | last post by:
Hi there, I am building a database that requires cascading lists on a form. I currently have (I may be adding more later) 3 combo boxes on my form - Department, Surname and Forename. The user...
2
by: arunj82 | last post by:
Hi, In my php page i have combo box which has problem numbers. Eg: Select the Problem ID to view the Problems : <select name="proid" onChange="dispValues()"> <option...
2
by: biganthony via AccessMonster.com | last post by:
Hi, I decided to install Office 2003 Service Pack 3 on my home computer to test (in full knowledge that there may be some issues with it). After installation, I have noticed that with a small...
4
by: Gilberto | last post by:
Hello, I have a couple of forms using the code to FIND AS YOU TYPE from Allen Browne (http://allenbrowne.com/AppFindAsUType.html). It worked PERFECTLY until yesterday when i splitted the db into...
2
by: Infog | last post by:
Using this code, the display member of the combo box is displaying the text "System.Data.DataViewManagerListItemTypeDescriptor". Huh??? The first block of code gets the data from the database, and...
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
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
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...
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...

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.