-
January 23rd, 2009, 11:28 AM
#1
DataGridViewComboBoxCell selected index
I have a datagridview that the user can add and delete rows from. one of the columns is a DataGridViewComboBoxColumn. i want to be able to loop through each row in the grid and get the selected index of the combo box for that row. i've tried everything i can think off but can't get it to work. could anyone help me?
something like this:
Code:
for (int i = 0; i < DataGridView.Rows.Count; i++)
{
MessageBox.Show(DataGridView.Rows[i].Cells["ComboBoxColumn"].SelectedIndex.ToString();
}
but obviously this doesn't work because it returns the value of the cell rather than the actual combo box
-
January 28th, 2009, 07:20 AM
#2
Re: DataGridViewComboBoxCell selected index
I assumed that you bind the ComboBox column to the data source. If yes, ValueMember property of the column should return value of the selected item in the combobox.
www.madartsoft.com C# controls, Help Desk Software
-
January 28th, 2009, 07:27 PM
#3
Re: DataGridViewComboBoxCell selected index
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|