private void Button_Click(object sender, RoutedEventArgs e) { listBox.Items.Clear(); // Get the selected items of SfDataGrid var reflector = this.dataGrid.View.GetPropertyAccessProvider(); var row = this.dataGrid.SelectedItem; foreach (var column in dataGrid.Columns) { //Get the value from data object based on MappingName var cellvalue = reflector.GetValue(row, column.MappingName); //Returns the display value of the cell from data object based on MappingName //var displayValue = reflector.GetFormattedValue(row, column.MappingName); listBox.Items.Add(cellvalue.ToString()); } } |
private void Button_Click_1(object sender, RoutedEventArgs e) { if (this.dataGrid.SelectedItem != null) { listbox.Items.Clear(); var reflector = this.dataGrid.View.GetPropertyAccessProvider(); var row = this.dataGrid.SelectedItem;
//Get the value from data object based on Column index var cellvalue = dataGrid.Columns[1].MappingName; // Use any column index var cell_value = reflector.GetValue(row, cellvalue);// Reflect the cell Value
listbox.Items.Add(cell_value.ToString()); } |
We have also prepared the sample based on this and please find the sample under the following location,
Sample: http://www.syncfusion.com/downloads/support/forum/123243/ze/CellValue1895583630
Regards,
Srinivasan