Advertisement
Guest User

Untitled

a guest
Jul 27th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
  2. {
  3. if (e.RowIndex >= 0 && e.RowIndex == 3)
  4. DoSomething(e.RowIndex, e.ColumnIndex);
  5. }
  6.  
  7. public void DoSomething(int row, int column)
  8. {
  9. MessageBox.Show(string.Format("Cell({0},{1}) Clicked", row, column));
  10. }
  11.  
  12. private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
  13. {
  14. var cell = this.dataGridView1.CurrentCell;
  15. if (cell != null && e.KeyCode == Keys.Enter &&
  16. cell.RowIndex >= 0 && cell.ColumnIndex == 3)
  17. {
  18. DoSomething(cell.RowIndex, cell.ColumnIndex);
  19. e.Handled = true;
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement