This is a migrated thread and some comments may be shown as answers.

OnLostFocus virtual method not called

3 Answers 16 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 2
Veteran
Iron
Patrick asked on 08 May 2014, 09:22 AM
Hello,
I have created a new control that inherits RadAutoCompleteBox and I need to make some work when the control lost its focus.
I have written a OnLostFocus method that overrrides the base method, but it is unfortunately never called.
Is this a bug?
Patrick

3 Answers, 1 is accepted

Sort by
0
Accepted
Kalin
Telerik team
answered on 09 May 2014, 12:20 PM
Hello Patrick,

You should either override OnLostKeyboardFocus method or subscribe to the LostFocus event the following way in the constructor:

public CustomAutoCompleteBox()
{
    this.LostFocus += CustomAutoCompleteBox_LostFocus;
}

Hope this helps.

Regards,
Kalin
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Patrick
Top achievements
Rank 2
Veteran
Iron
answered on 12 May 2014, 03:49 PM
Hello Kalin,
thanks you the tip: it works.

But it seems that there is a bug in the control code: by .NET patterns, the OnLostFocus methos MUST be called to raise the LostFocus event. So overriding the OnXXX method on an inherited class is the same as attaching to the XXX event.

Patrick
0
Kalin
Telerik team
answered on 13 May 2014, 11:06 AM
Hi Patrick,

This is so in the particular scenario because of the WatermarkTextBox used inside of the AutoCompleteTextBox ControlTemplate. When you focus the AutoCompleteBox, the WatermarkTextBox element inside actually gets the focus and afterwards when the focus is lost the OnLostFocus method of the WatermarkTextBox is triggered.

Hope this helps.

Regards,
Kalin
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
AutoCompleteBox
Asked by
Patrick
Top achievements
Rank 2
Veteran
Iron
Answers by
Kalin
Telerik team
Patrick
Top achievements
Rank 2
Veteran
Iron
Share this question
or