摘要:DataGridViewComboBoxCell 值無效
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
// 使用Items.Clear()之前, 先將Value = null
// 就可避免觸發dataGridView1_DataError
dataGridView1.CurrentRow.Cells["ColumnName1"].Value = null;
(DataGridViewComboBoxCell)dataGridView1.CurrentRow.Cells["ColumnName1"]).Items.Clear();
}
private void dataGridView1_DataError(object sender, DataGridViewDataErrorEventArgs e)
{
// e.Exception = DataGridViewComboBoxCell 值無效
// e.Context = formatting | Display
if (e.Exception != null && e.Context == DataGridViewDataErrorContexts.Commit)
{
MessageBox.Show("Commit error");
}
}