Articles in this section

How to get cell value before loading the Grid in WinForms DataGrid?

WinForms DataGrid (SfDataGrid) allows you to retrieve the cell values before the DataGrid is loaded by using SfDataGrid.View.Records collection.

public Form1()
{
    InitializeComponent();
    sfDataGrid1.DataSource = new OrderInfoCollection().OrdersListDetails;

    if (this.sfDataGrid1.RowCount > 0)
        sfDataGrid1.MoveToCurrentCell(new RowColumnIndex(2, 0));

    var record = this.sfDataGrid1.View.Records[this.sfDataGrid1.TableControl.ResolveToRecordIndex(this.sfDataGrid1.CurrentCell.RowIndex)];
    var currentCellValue = this.sfDataGrid1.View.GetPropertyAccessProvider().GetValue((record as RecordEntry).Data, "OrderID");
    MessageBox.Show("CurrentCell value = " + currentCellValue.ToString());
}

Take a moment to peruse the WinForms DataGrid - Selection documentation, where you can find about selection, with code examples.

View sample in GitHub

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied