我有一个单元格点击事件,用于在消息框中显示所点击单元格的数据,在数据网格视图中。 我已将其设置为仅适用于特定列,并且仅当该单元格中存在数据时才起作用。
然而,每当我点击任何列标题时,一个空白消息框会出现。我无法弄清原因,有什么提示吗?
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (dataGridView1.CurrentCell.ColumnIndex.Equals(3))
if (dataGridView1.CurrentCell != null && dataGridView1.CurrentCell.Value != null)
MessageBox.Show(dataGridView1.CurrentCell.Value.ToString());
}
然而,每当我点击任何列标题时,一个空白消息框会出现。我无法弄清原因,有什么提示吗?
dataGridView1.CurrentCell != null
。 - MatanKri