Click here to Skip to main content
15,889,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Every One,

I am making a window project. On a Page i am using datagridview. in datagridview i am using a DataGridViewComboBoxColumn. for this i use following code
C#
DataGridViewComboBoxColumn dgvcmb = new DataGridViewComboBoxColumn();
dgvcmb.DisplayMember = "cust_name";
dgvcmb.ValueMember = "cust_ID";


"cust_name" and "cust_id" are two database columns. Now i want to get the value of "cust_ID" in "cellbeginedit" and "cellvaluechanged" events of datagridview. but i could not find this. i am not getting code to get them.


please help me.
Posted
Updated 20-Dec-19 0:59am
v3

In either one of those events you should be able to get the cust_ID value like this:
C#
( ( DataGridView ) sender ).CurrentCell.Value

To get the display name:
C#
( ( DataGridView ) sender ).CurrentCell.EditedFormattedValue
 
Share this answer
 
v2
e.Row.Cell["{RequiredCellName}"].Value.ToString();
 
Share this answer
 
Comments
CHill60 20-Dec-19 7:06am    
You have added nothing to solution that was posted over 7 years ago!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900