DataGrid get selected rows' column values

前端 未结 8 1327
你的背包
你的背包 2020-11-27 06:11

I\'m trying to get the values of each column of a selected row in a DataGrid. This is what I have:

private void dataGrid1_CellEditEnding(object sender, DataG         


        
8条回答
  •  迷失自我
    2020-11-27 06:38

    I used a similar way to solve this problem using the animescm sugestion, indeed we can obtain the specific cells values from a group of selected cells using an auxiliar list:

    private void dataGridCase_SelectionChanged(object sender, SelectedCellsChangedEventArgs e)
        {
            foreach (var item in e.AddedCells)
            {
                var col = item.Column as DataGridColumn;
                var fc = col.GetCellContent(item.Item);
                lstTxns.Items.Add((fc as TextBlock).Text);
            }
        }
    

提交回复
热议问题