some_yahoo

Edit Row on F2

Sep 1st, 2011
367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 KB | None | 0 0
  1.         // These routines manage the "Edit on F2" feature where the entire row
  2.         // goes into edit mode on keypress of the F2 key.
  3.         // make sure you attach them to all the grids in your project
  4.         private void Grid_KeyUp(object sender, KeyEventArgs e)
  5.         {
  6.             DataGridView dg = (sender as DataGridView);
  7.             if (e.KeyCode == Keys.F2)
  8.             {
  9.                 if (dg.EditMode != DataGridViewEditMode.EditOnKeystroke)
  10.                 {
  11.                     dg.EditMode = DataGridViewEditMode.EditOnKeystroke;
  12.                     dg.BeginEdit(false);
  13.                 }
  14.             }
  15.         }
  16.  
  17.         private void Grid_RowLeave(object sender, DataGridViewCellEventArgs e)
  18.         {
  19.             DataGridView dg = (sender as DataGridView);
  20.             save();
  21.             dg.EditMode = DataGridViewEditMode.EditProgrammatically;
  22.         }
Advertisement
Add Comment
Please, Sign In to add comment