Tech Off Thread

4 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

What event fires when you click the pencil on a datagrid in WinForms

Back to Forum: Tech Off
  • User profile image
    qwert231

    I'm sure this is all over the place, maybe I'm missing it. When a user changes data in the datagrid, the row header get's it's little pencil icon. When they click it, what event is fired?

  • User profile image
    DCMonkey

    I don't think there is one. At least these guys never found one.
    You can however intercept the click before the pencil goes away by subclassing the DataGrid and overriding OnMouseDown like so (whether this is useful depends on what you are trying to do. I'm no expert on the DataGrid either. I've avoided it in what little WinForms programming I've done because it was so horribly limited):

    public class MyDataGrid : DataGrid 
    {
       protected override void OnMouseDown(MouseEventArgs e) 
       {
          DataGrid.HitTestInfo hit = this.HitTest(e.X, e.Y);
          if(hit.Type == DataGrid.HitTestType.RowHeader)
             {
                MessageBox.Show("Row " + hit.Row);
             }
          else
          {
             base.OnMouseDown(e);
          }
       }
    }







  • User profile image
    Tensor

    The first thing most winforms developers do is get another grid.

    The 2.0 grid is a lot better, though.

  • User profile image
    qwert231

    Currently I catch the CellChanged event and pass anything in my dataset.getchanges to my update command, which works. But what's a good way to fill into the datagrid the ident column values?

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.