Hi
You can use this below code to solve the issue of DataGridViewComboBoxColum.It will help you.
private void dataGridView1_EditingControlShowing(object sender,
DataGridViewEditingControlShowingEventArgs e)
{
if (dataGridView1.CurrentCell.ColumnIndex == 0)
{
// Check box column
ComboBox comboBox = e.Control as ComboBox;
comboBox.SelectedIndexChanged += new EventHandler(comboBox_SelectedIndexChanged);
}
}
void comboBox_SelectedIndexChanged(object sender, EventArgs e)
{
int selectedIndex = ((ComboBox)sender).SelectedIndex;
MessageBox.Show("Selected Index = " + selectedIndex);
}
If you want to more detail about code than just go for below link.
http://generally.wordpress.com/2007/12/07/datagridview-get-selectedindex-of-datagridviewcomboboxcolumn/
You can use this below code to solve the issue of DataGridViewComboBoxColum.It will help you.
private void dataGridView1_EditingControlShowing(object sender,
DataGridViewEditingControlShowingEventArgs e)
{
if (dataGridView1.CurrentCell.ColumnIndex == 0)
{
// Check box column
ComboBox comboBox = e.Control as ComboBox;
comboBox.SelectedIndexChanged += new EventHandler(comboBox_SelectedIndexChanged);
}
}
void comboBox_SelectedIndexChanged(object sender, EventArgs e)
{
int selectedIndex = ((ComboBox)sender).SelectedIndex;
MessageBox.Show("Selected Index = " + selectedIndex);
}
If you want to more detail about code than just go for below link.
http://generally.wordpress.com/2007/12/07/datagridview-get-selectedindex-of-datagridviewcomboboxcolumn/
Comments
Post a Comment