Question : Event that fires during DataGridViewComboBoxColumn SelectedIndexChanged
Answered by : bewildered-badger-jh2zw9xeie70
private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { if (dataGridView1.CurrentCell.ColumnIndex == 1 && e.Control is ComboBox) { ComboBox comboBox = e.Control as ComboBox; comboBox.SelectedIndexChanged -= LastColumnComboSelectionChanged; comboBox.SelectedIndexChanged += LastColumnComboSelectionChanged; } } private void LastColumnComboSelectionChanged(object sender, EventArgs e) { var currentcell = dataGridView1.CurrentCellAddress; var sendingCB = sender as DataGridViewComboBoxEditingControl; DataGridViewTextBoxCell cel = (DataGridViewTextBoxCell)dataGridView1.Rows[currentcell.Y].Cells[0]; cel.Value = sendingCB.EditingControlFormattedValue.ToString(); }
Source : https://stackoverflow.com/questions/11141872/event-that-fires-during-datagridviewcomboboxcolumn-selectedindexchanged | Last Update : Fri, 13 May 22