Datagrid frustartions

  • Thread starter Thread starter Bill Styles
  • Start date Start date
B

Bill Styles

I've been trying to do some work with a datagrid control on a winform and
have gotten very frustrated with it. I need to be able to determine when
the user clicks on a given cell but can't find anything that seems to be
reliable.

The click and doubleclick events fire when the user clicks on the row or
column headers and *sometimes* when the user clicks on a particular cell. I
can't figure out any pattern to when it fires by clicking on a cell.

The CurrentCellChanged fires when the user clicks on a cell but ALSO when
the user clicks on a different row or column header so if they select a cell
and then click a column header to sort differently then it changes the
selection. I need to identify the last cell selected only and not have it
be affected by row or column clicks.

There are a lot of other things that should be simple that the datagrid
seems to make as difficult as possible but I've managed to work around
everything so far except the ability to select a cell. Any ideas will be
appreciated.
 
Hello Bill,

Use the MouseUp event (or MouseDown, depending on what you want to do upon a
click) and then use the HitTest method on the grid instance to determine
whether the user has clicked on a cell, on a row header, on a column header
etc.
 
Dmitriy Lapshin said:
Hello Bill,

Use the MouseUp event (or MouseDown, depending on what you want to do
upon a click) and then use the HitTest method on the grid instance to
determine whether the user has clicked on a cell, on a row header, on
a column header etc.

Excellent, thanks! That appears to be a viable option from the quick tests
I just did. Now I can create a wrapper that provides the events I really
need.
 
Back
Top