DataGrid Row Selection

  • Thread starter Thread starter John Smith
  • Start date Start date
J

John Smith

Hey folks,

Is there a way to make the data grid always select a row only and not an
individual cell?

Like...When I click on the row header it highlights the whole row in blue.
But when I then click on a cell in another row, it selects just that cell.
I don't want that. I want it to behave the same way as when clicking on the
row header.

Thanks!
 
Sure, just use Select() to select the row, e.g.

myDataGrid.Select(CurrentCell.RowNumber);

Just do this every time a new cell is selected.

--
Kai Brinkmann [MSFT]

Please do not send e-mail directly to this alias. This alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.
 
But then how can I capture the double click of a row? Cells don't seem to
have a double click event.


Kai Brinkmann said:
Sure, just use Select() to select the row, e.g.

myDataGrid.Select(CurrentCell.RowNumber);

Just do this every time a new cell is selected.

--
Kai Brinkmann [MSFT]

Please do not send e-mail directly to this alias. This alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


John Smith said:
Hey folks,

Is there a way to make the data grid always select a row only and not an
individual cell?

Like...When I click on the row header it highlights the whole row in blue.
But when I then click on a cell in another row, it selects just that cell.
I don't want that. I want it to behave the same way as when clicking on the
row header.

Thanks!
 
No, but the DataGrid control has both Click and DoubleClick events. All you
need to do is identify the selected row or cell in the event handlers for
these events and write the appropriate code. The CurrentCellChanged event
might also be helpful.

--
Kai Brinkmann [MSFT]

Please do not send e-mail directly to this alias. This alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


John Smith said:
But then how can I capture the double click of a row? Cells don't seem to
have a double click event.


Kai Brinkmann said:
Sure, just use Select() to select the row, e.g.

myDataGrid.Select(CurrentCell.RowNumber);

Just do this every time a new cell is selected.

--
Kai Brinkmann [MSFT]

Please do not send e-mail directly to this alias. This alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


John Smith said:
Hey folks,

Is there a way to make the data grid always select a row only and not an
individual cell?

Like...When I click on the row header it highlights the whole row in blue.
But when I then click on a cell in another row, it selects just that cell.
I don't want that. I want it to behave the same way as when clicking
on
the
row header.

Thanks!
 
But I mean, I was expecting to have the ability to double click anywhere on
a row and have it fire the double click event. But now it seems the only
way you can doubleclick is to click on the row header?

The CurrentCellChanged event is single click (in which case the row is just
selected).


Kai Brinkmann said:
No, but the DataGrid control has both Click and DoubleClick events. All you
need to do is identify the selected row or cell in the event handlers for
these events and write the appropriate code. The CurrentCellChanged event
might also be helpful.

--
Kai Brinkmann [MSFT]

Please do not send e-mail directly to this alias. This alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


John Smith said:
But then how can I capture the double click of a row? Cells don't seem to
have a double click event.


Kai Brinkmann said:
Sure, just use Select() to select the row, e.g.

myDataGrid.Select(CurrentCell.RowNumber);

Just do this every time a new cell is selected.

--
Kai Brinkmann [MSFT]

Please do not send e-mail directly to this alias. This alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


Hey folks,

Is there a way to make the data grid always select a row only and
not
clicking
 
Back
Top