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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Detecting Lost Focus to commit changes

Thread ID:

Created:

Updated:

Platform:

Replies:

142817 Feb 20,2019 07:51 PM UTC Mar 28,2019 12:56 PM UTC WinForms 3
loading
Tags: Spreadsheet
Spotty
Asked On February 20, 2019 07:51 PM UTC

I have a spreadsheet and it has some dropdown list validation.   I want to detect when the spreadsheet or cell loses focus such as when I click a button outside of the grid so that I can then commit that value.

The spreadsheet lost focus event doesnt seem to be the one to use or it doesnt fire when I'm expecting it to.



Arulraj A [Syncfusion]
Replied On February 22, 2019 09:28 AM UTC

Hi Spotty, 

Thanks for using Syncfusion product. 

By default, If cell is in edit mode, focus will not loss until you commit the value using press the enter key or navigate to next cell. This is the excel behavior.  To achieve your reported scenario, you could implement the custom cell renderer for SpreadsheetTextBoxCellRenderer and override the OnEditElementLostFocus method. Please refer the following code example and the sample. 

VB 
AddHandler Me.spreadsheet.WorkbookLoaded, AddressOf Spreadsheet_WorkbookLoaded 
 
Private Sub Spreadsheet_WorkbookLoaded(ByVal sender As Object, ByVal args As Syncfusion.Windows.Forms.Spreadsheet.Helpers.WorkbookLoadedEventArgs) 
    Me.spreadsheet.ActiveGrid.CellRenderers("TextBox") = New CustomTextBoxCellRenderer() 
End Sub 
 
Partial Class CustomTextBoxCellRenderer 
    Inherits Syncfusion.Windows.Forms.Spreadsheet.CellRenderer.SpreadsheetTextBoxCellRenderer 
    Public Sub New() 
    End Sub 
 
    Protected Overrides Sub OnEditElementLostFocus(sender As Object, e As EventArgs) 
        MyBase.OnEditElementLostFocus(sender, e) 
        'To commit the cell value. 
        Me.Grid.CurrentCell.EndEdit() 
    End Sub 
End Class 
 
 
 
Please get back to us if you need any further assistance on this. 

Arulraj A 


Spotty
Replied On March 27, 2019 09:58 PM UTC

Im not sure that you have the right scenario here.   I have some data validation on a cell - resulting in a dropdown list box.   When I click on a button outside the spreadsheet control I want to commit the edit into the spreadsheet prior to performing the button click code.

The code same works when I click out of dropdown to another cell in the spreadsheet but not when I click on a control outside of the sheet - when I also want to commit the edit prior to carrying out the action. 

Attachment: UpdateLostfocus_b1f5fff9.zip

Mohanraj Gunasekaran [Syncfusion]
Replied On March 28, 2019 12:56 PM UTC

Hi Spotty,  
 
Thanks for your update. 
 
The reported scenario is default excel behavior. If you use the ComboBox column for cell, the cell values will not commit until click on any cell. So, we can’t change this behavior. Please find the following excel video demo link 
 
 
Please get back to us if you need any further assistance on this. 
 
Regards, 
Mohanraj G 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

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

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

;