private void dataGridView1_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { // Retrieve information about the clicked cell int rowIndex = e.RowIndex; int columnIndex = e.ColumnIndex; DataGridViewCell clickedCell = dataGridView1.Rows[rowIndex].Cells[columnIndex]; object cellValue = clickedCell.Value; // Do something with the cell information... }
private void dataGridView1_CellMouseEnter(object sender, DataGridViewCellEventArgs e) { // Highlight the cell that the cursor entered DataGridViewCell enteredCell = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex]; enteredCell.Style.BackColor = Color.Yellow; }Both of these examples use the System.Windows.Forms namespace, which contains the DataGridView control and other classes for creating Windows Forms applications in C#.