Perform Selection Only On Lost Focus or Enter Key Press

By default, when an item is matched by the text entered in an editable RadComboBox, it will instantaneously be set as the SelectedItem of the control. The same result is observed when navigating through the items with the keyboard. Setting the UpdateSelectionOnLostFocus property to True overrides this behavior and the selection will only be updated when the focus is moved out of the control or the Enter key is pressed.

The property affects only an editable RadComboBox with single selection.

Example 1: Set the UpdateSelectionOnLostFocus property

<telerik:RadComboBox IsEditable="True" UpdateSelectionOnLostFocus="True"> 
    <telerik:RadComboBoxItem Content="Item 1" /> 
    <telerik:RadComboBoxItem Content="Item 2" /> 
    <telerik:RadComboBoxItem Content="Item 3" /> 
</telerik:RadComboBox> 
When the UpdateSelectionOnLostFocus property is set to true, you have to take into account the following scenarios when the control loses focus or the Enter key is pressed:
  • When SelectedItem/SelectedValue property is null: When the typed text matches any of the items in the RadComboBox, the SelectedItem/SelectedValue property will be set to the first item.

  • When SelectedItem/SelectedValue property is null: When the typed text does not match any of the items in the RadComboBox, the SelectedItem/SelectedValue property will be null, and the Text property of the control will hold the typed text.

  • When SelectedItem/SelectedValue property is not null : When the typed text does not match any of the items in the RadComboBox, the SelectedItem/SelectedValue property will be set to null, and the Text property of the control will be cleared.

UpdateSelectionOnLostFocus and UpdateTextOnLostFocus

With the 2021 R1 LIB 322 version of our controls, we have introduced the UpdateTextOnLostFocus property to control whether the Text property should be updated when the control loses focus. The default value of this property is True.

When the UpdateSelectionOnLostFocus property is set to true and UpdateTextOnLostFocus property is set to false, you have to take into account the following scenarios when the control loses focus or the Enter key is pressed:

  • When SelectedItem/SelectedValue property is null: When the typed text matches any of the items in the RadComboBox, the SelectedItem/SelectedValue property will be set to the first item. The Text property will hold the text of the selected item.

  • When SelectedItem/SelectedValue property is null: When the typed text does not match any of the items in the RadComboBox, the SelectedItem/SelectedValue property will be null, and the Text property of the control will hold the typed text.

  • When SelectedItem/SelectedValue property is not null: When the typed text does not match any of the items in the RadComboBox, the SelectedItem/SelectedValue property will be set to null, and the Text property of the control will hold the typed text.

You can have a look at the Configurator demo from the Silverlight Controls Samples to get a better understanding of how the UpdateSelectionOnLostFocus property works.

See Also

In this article