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. Image for the cookie policy date

control lost focus

When the grid control lost focus, we need to save some data. Is there any event with CancelEventArgs raised at this case, so I can use e.cancel = true to prevent this grid control to lose focus? Thanks Hui

9 Replies

AD Administrator Syncfusion Team February 14, 2006 07:29 AM UTC

Hi Hui, There is no event with CancelEventArg on control lost focus. But the focus can be set back in the LostFocus event handler by calling the grid.Focus(); method, which wont allow the focus to be lost. Regards, Calvin.


HZ Hui Zhong February 14, 2006 04:18 PM UTC

Please see the attached example. Our original design is to save the data when the row is changed or the grid control lost focus, which could be the case like the user click other control on the form, or this form closed. If save fails, we want to display the error messge, and the grid control get focus again. If set the debug point in the event of gridControl1_LostFocus, gridControl1.Focus() does work. However, if there is no debug point set there, the LostFocus event is not raised, and the gridControl1 does lose control. Hui >Hi Hui, > >There is no event with CancelEventArg on control lost focus. But the focus can be set back in the LostFocus event handler by calling the grid.Focus(); method, which wont allow the focus to be lost. > >Regards, >Calvin.

WindowsApplication25.zip


AD Administrator Syncfusion Team February 15, 2006 04:40 PM UTC

Hi Hui, Try handling the Grid’s Validating event to see if that helps. Attached a sample. Regards, Calvin.

40795.zip


HZ Hui Zhong February 15, 2006 05:53 PM UTC

Thanks, Calvin. Actually yesterday after I sent my example code, I tried the Validating event, it worked for me. However, when I merge this code to our project. The validating was not raised if clicking other control on the form. I will try to figure out why, and may come back to you later. Hui >Hi Hui, > >Try handling the Grid’s Validating event to see if that helps. Attached a sample. > >Regards, >Calvin.

40795.zip


HZ Hui Zhong February 15, 2006 09:59 PM UTC

I figured it out. When the grid control is added at runtime, set tabindex = 0 will raise the validating event when move the focus out of this grid control >Thanks, Calvin. >Actually yesterday after I sent my example code, I tried the Validating event, it worked for me. > >However, when I merge this code to our project. The validating was not raised if clicking other control on the form. > >I will try to figure out why, and may come back to you later. > >Hui > >>Hi Hui, >> >>Try handling the Grid’s Validating event to see if that helps. Attached a sample. >> >>Regards, >>Calvin.

40795.zip


HZ Hui Zhong February 16, 2006 06:21 PM UTC

I still have some problems with the validating event. I don''t have the issue with the example, because the event handling is quite simple. However, in the project I am working on, we implemented a lot events, and the validating() event of the grid is not raised when I clicked on other controls (like button..) in the form. Do you have some idea on it? Thanks. Hui > >I figured it out. When the grid control is added at runtime, set tabindex = 0 will raise the validating event when move the focus out of this grid control > >>Thanks, Calvin. >>Actually yesterday after I sent my example code, I tried the Validating event, it worked for me. >> >>However, when I merge this code to our project. The validating was not raised if clicking other control on the form. >> >>I will try to figure out why, and may come back to you later. >> >>Hui >> >>>Hi Hui, >>> >>>Try handling the Grid’s Validating event to see if that helps. Attached a sample. >>> >>>Regards, >>>Calvin.

40795.zip


ST stanleyj Syncfusion Team February 17, 2006 02:08 PM UTC

Hi Hui, Please ensure that CausesValidation of those controls like button are set to true. Best regards, Stanley


PA park replied to Administrator February 26, 2018 01:26 AM UTC

Hi Hui, Try handling the Grid’s Validating event to see if that helps. Attached a sample. Regards, Calvin.

40795.zip

ok


SN Sindhu Nagarajan Syncfusion Team February 26, 2018 10:45 AM UTC

Hi Hui, 
  
Thanks for your update.  
Please let us know if you have any other queries. 
  
  
Regards, 
Sindhu. 


Loader.
Live Chat Icon For mobile
Up arrow icon