Datagridview ComboboxCell选中项变化时触发事件
private void Form1_Load(object sender, EventArgs e)
{
List<string> list = new List<string>();
list.Add("1");
list.Add("2");
list.Add("3");
dgv_cb.DataSource = list;
}
// Save the row index
int RowIndex;
private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
RowIndex = dataGridView1.CurrentCell.RowIndex;
if (dataGridView1.CurrentCell.ColumnIndex == 0)
{
ComboBox comboBox = e.Control as ComboBox;
comboBox.SelectedIndexChanged += new EventHandler(comboBox_SelectedIndexChanged);
}
}
void comboBox_SelectedIndexChanged(object sender, EventArgs e)
{
// Set the value of column "dgv_txt"
dataGridView1.Rows[RowIndex].Cells[1].Value = ((ComboBox)sender).Text;
}
触发事件,修改”dgv-txt“中的值,
把圈子变小,把语言变干净,把成绩往上提,把故事往心里收,现在想要的以后你都会有。