26

When I click a cell in a WPF datagrid, the whole row is selected, and when I press Ctrl + C to copy the content, the whole row i copied...

How do I select and copy the content of a single cell?

David Brunelle
  • 6,528
  • 11
  • 64
  • 104
epsen
  • 263
  • 1
  • 3
  • 5

3 Answers3

44

Use SelectionUnit Property of Datagrid. For example:

dataGridView1.SelectionUnit = DataGridSelectionUnit.Cell;

Where unit can be Cell, CellOrRowHeader or FullRow.

Balle
  • 464
  • 5
  • 4
3

WPF datagrid comes up with the 'SelectionUnit' property.
You can set the following values 'SingleCell/FullRow/CellorRowHeader'.
If you want to select multiple rows, use the 'SelectionMode' property and set the value to 'Extended.'

Hunter
  • 2,370
  • 2
  • 20
  • 24
0

This is an option in the WPF grid, you should have a property named SelectionMode (or something like that depending of the datagrid you're using) that define how cells are selected.

David Brunelle
  • 6,528
  • 11
  • 64
  • 104
  • SelectionMode is for how many of the specified SelectionUnit can be selected. – N_A Jan 18 '12 at 03:21
  • I think it's actually a helpful bit of information to be associated with this question. I recently needed both (which is why I found this question). – N_A Jan 18 '12 at 17:20