Hi Tiago,
Thank you for using Syncfusion controls.
SfDataGrid is data bounded. So, SfDataGrid doesn’t have the support to get the cell value as like as DataGridView by using Row and Column index. You can achieve your requirement to get the cell value in SfDataGrid as like as DataGridView by using the DataGridHelper class GetCellValue method.
Please refer the below code snippet.
private void button1_Click(object sender, EventArgs e)
{
if (this.sfDataGrid.SelectionController.DataGrid.CurrentCell.ColumnIndex != -1 &&this.sfDataGrid.SelectionController.DataGrid.CurrentCell.RowIndex != -1)
{
var rowIndex = this.sfDataGrid.SelectionController.DataGrid.CurrentCell.RowIndex;
var recordIndex = sfDataGrid.TableControl.ResolveToRecordIndex(rowIndex);
var cellValue = DataGridHelper.GetCellValue(this.sfDataGrid, recordIndex, 2);
MessageBox.Show("Value in cell " + cellValue.ToString());
}
}
public static class DataGridHelper
{
public static object GetCellValue(SfDataGrid sfDataGrid, int recordIndex, intcolumnindex)
{
object cellValue = null;
var record1 = sfDataGrid.View.Records.GetItemAt(recordIndex);
var mappingName = sfDataGrid.Columns[columnindex].MappingName;
cellValue = record1.GetType().GetProperty(mappingName).GetValue(record1, null);
if (cellValue != null)
{
return cellValue;
}
return null;
}
} |
Please refer the below sample link.
Please refer the below UG link.
Please let us know, If you require further assistance on this.
Regards,
Gowtham