Simulating mouse click on DataGrid RowHeader

  • Thread starter Thread starter Barry Anderberg
  • Start date Start date
B

Barry Anderberg

The Windows Forms DataGrid supports control-click multiple selection
of rows, but it only works when you click the row header.

I am trying to set up the DataGrid so that clicking anywhere on a row
will be just like clicking the row header.

I could implement my own code to track which rows are selected, etc.,
but that's a lot of code that I don't think is necessary.

I need a way to trick the DataGrid into thinking the user clicked the
header of the row.

I intercept the mouse click in the DataGrid.MouseDown event, and I
know how to use the HitTest to figure out which row the user clicked
on, I just have no idea how to simulate a click on the corresponding
row header.

One thing I tried was to inherit from the DataGrid class, override the
OnMouseDown method, and from there call base.OnRowHeaderClick but the
issue there is that OnMouseDown takes a MouseEventArgs object and
OnRowHeaderClick takes an EventArgs object, so I'm thinking there's
some information normally sent to the RowHeaderClick event that I
can't get at.

Anyway, please help me! I have no idea how to do this. I've spent
the entire day researching this.
 
Back
Top