I have an event for a cell click in a datagrid view to display data in a cell with a click in the message box. I found that it only works for a specific column and only if there is data in the cell
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()); }
however, whenever I click on any of the column headings, a blank message appears. I canβt understand why, any advice?
source share