Articles in this section
Category / Section

How to read the cell value while the cell is still in edit mode of WinForms Spreadsheet (SfSpreadsheet)?

1 min read

Read the cell value in edit mode

The WinForms Spreadsheet (SfSpreadsheet) provides support to read the cell value while the cell is in edit mode. You can get the value of current cell in edit mode by hooking CurrentCellValueChanged event and accessing the value from ControlText property. The CurrentCellValueChanged event will be triggered when entering each and every character into the cell.

C#

Spreadsheet.ActiveGrid.CurrentCellValueChanged += ActiveGrid_CurrentCellValueChanged;
private void ActiveGrid_CurrentCellValueChanged(object sender,CurrentCellValueChangedEventArgs args)
{
    var cellvalue = args.ControlText; // Gets the text of cell in edit mode
}

You can also get the value of edited cell by using CurrentCellValidating event. For this, you need to call the Validate method of SpreadsheetCurrentCell.

C#

//This call will trigger the CurrentCellValidating event.
Spreadsheet.ActiveGrid.CurrentCell.Validate(out isValid);
Spreadsheet.ActiveGrid.CurrentCellValidating += ActiveGrid_CurrentCellValidating;
private void ActiveGrid_CurrentCellValidating(object sender,CurrentCellValidatingEventArgs args)
{
    var cellvalue = args.NewValue; // Gets the value of cell in edit mode  
}
bool isValid = true;

 

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