I have a DataGridView
. Its Cell_Content_Click
is not firing each time I select a cell. It does fires but not at each click.
I want to get content of selected cell in my string variable 'selected'. Here is what I am doing:
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null)
{
selected = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
}
}
The CellContentClick
event only fires when the content (text) inside a cell is clicked.
Use the CellClick
event instead of CellContentClick
, since that event fires when any part of the cell is clicked (not just the content inside it).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With