Click here to Skip to main content
15,886,067 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hi,
I am using a datagrid and I set to the SelectionMode property to "multiple cells"
and data grid has 1000 records with 7 columns.
I just want to store the contents of the cells in the string from only the cells that I selected in the DataGrid how to accomplish this task?

Thanks in Advance
Posted
Updated 18-Mar-11 2:48am
v2

1 solution

You can get the selected cells values using the DataGrid.SelectedCells property and GetCellContent method of the DataGridColumn. For example:

for (int i = 0; i < this.datagrid.SelectedCells.Count; i++)
 {
      Console.WriteLine((this.datagrid.SelectedCells[i].Column.GetCellContent 
     (this.datagrid.SelectedCells[i].Item) as TextBlock).Text);
 }


Hope this helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900