| // Get the CurrentCellValue var currentCellValue = sfDataGrid.CurrentCell.CellRenderer.GetControlValue(); |
| // Get the cell value for RowIndex = 5 and ColumnIndex = 3 int rowIndex = 5; int columnIndex = sfDataGrid.TableControl.ResolveToGridVisibleColumnIndex(3); if (columnIndex < 0) return; var mappingName = sfDataGrid.Columns[columnIndex].MappingName; var recordIndex = sfDataGrid.TableControl.ResolveToRecordIndex(rowIndex); if (recordIndex < 0) return; if (sfDataGrid.View.TopLevelGroup != null) { var record = sfDataGrid.View.TopLevelGroup.DisplayElements[recordIndex]; if (!record.IsRecords) return; var data = (record as RecordEntry).Data; var cellVaue = (data.GetType().GetProperty(mappingName).GetValue(data, null).ToString()); } else { var record1 = sfDataGrid.View.Records.GetItemAt(recordIndex); var cellVaue = (record1.GetType().GetProperty(mappingName).GetValue(record1, null).ToString()); } |
| 'Get the cell value for RowIndex = 5 and ColumnIndex = 3 Dim rowIndex As Integer = 5 Dim columnIndex As Integer = sfDataGrid.TableControl.ResolveToGridVisibleColumnIndex(3) If columnIndex < 0 Then Return End If Dim mappingName = sfDataGrid.Columns(columnIndex).MappingName Dim recordIndex = sfDataGrid.TableControl.ResolveToRecordIndex(rowIndex) If recordIndex < 0 Then Return End If If sfDataGrid.View.TopLevelGroup IsNot Nothing Then Dim record = sfDataGrid.View.TopLevelGroup.DisplayElements(recordIndex) If Not record.IsRecords Then Return End If Dim data = (TryCast(record, RecordEntry)).Data Dim cellVaue = (data.GetType().GetProperty(mappingName).GetValue(data, Nothing).ToString()) Else Dim record1 = sfDataGrid.View.Records.GetItemAt(recordIndex) Dim cellValue = record1.GetType().GetProperty(mappingName).GetValue(record1, Nothing) Dim cellString = String.Empty If cellValue IsNot Nothing Then cellString = cellValue.ToString() End If MessageBox.Show(cellString) End If |
| 'Get the cell value for RowIndex = 5 and ColumnIndex = 3 Dim rowIndex As Integer = 5 Dim columnIndex As Integer = sfDataGrid.TableControl.ResolveToGridVisibleColumnIndex(3) If columnIndex < 0 Then Return End If Dim recordIndex = sfDataGrid.TableControl.ResolveToRecordIndex(rowIndex) If recordIndex < 0 Then Return End If Dim record1 = sfDataGrid.View.Records.GetItemAt(recordIndex) If record1 IsNot Nothing Then Dim cellValue = (TryCast(record1, DataRowView).Row.ItemArray(columnIndex)) Dim cellString = String.Empty If cellValue IsNot Nothing Then cellString = cellValue.ToString() End If MessageBox.Show(cellString) End If |