)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Platform: WinForms |
Control: Spreadsheet |
Published Date: July 28, 2016 |
Last Revised Date: January 24, 2020
Tags: editing

Read the cell value in edit mode

The 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;

 

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon