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

RadComboBoxElement & autocomplete

4 Answers 122 Views
Toolstrip (obsolete as of Q3 2010)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Loy Chan
Top achievements
Rank 1
Loy Chan asked on 14 Nov 2008, 07:10 PM
I use a Radcomboxelement on my toolbar as a staff filter. The combobox contains a large number of staff names and a "All" option. I've set it up to use autocomplete AppendSuggest.

The problem lies when after the user selects a specific staff and then wants to go back to the "All" option. Rather than scroll back up to the top, they want to the just clear the comboxbox text.

In the past, when I used the regular windows toolbar combobox, there's a "Leave" event that I can use to check the value of the combobox text and if it's blank, I'll set the selectedindex to the "all" option.

Unfortunately, the RadComboBoxElement class does not inherit from Control so it doesn't have this event.

Any suggestions?

4 Answers, 1 is accepted

Sort by
0
Loy Chan
Top achievements
Rank 1
answered on 14 Nov 2008, 08:10 PM
Another problem arises ...

If the user starts typing in the combobox element, the auto complete functionality (set to AppendSuggest) will display the matching item text. If the user presses "enter" then the item will be selected.

But if the user tabs away or clicks away (ie. combobox loses focus), the combobox text will remain but the selectedindex will not correspond to the displayed text.
0
Dimitar Kapitanov
Telerik team
answered on 18 Nov 2008, 05:11 PM
Hello Loy Chan,

As a workaround for your first problem you can use the TextBoxElement property of the RadComboBoxElement to obtain a real Leave event from the text control used inside the combobox. The code i:
 
(TextBoxElement.TextBoxItem.HostedControl as TextBox).Leave += .... 
 
There you can put the code you usually execute on leave.

Regarding your second problem, could you elaborate a bit more? By design you should explicitly set the index on pressing Enter. How does the behavior of our combobox deffer from the standard one provided with the .NET Framework?
 
 
Best wishes,
Dimitar Kapitanov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Loy Chan
Top achievements
Rank 1
answered on 18 Nov 2008, 07:10 PM
Thanks.

It worked exactly like i need it to.

Regarding my 2nd problem, I'm not sure exactly how a normal windows combo box is suppose to handle that situation but to me, it's a consistency issue. If I tab away from the combobox after I've typed in some text, I would look back at that combobox and think that the displayed text is actually the text of the selected item.

Regardless, I was able to handle the situation with the Leave event.

Thanks again.
0
Nikolay
Telerik team
answered on 21 Nov 2008, 03:08 PM
Hello Loy Chan,

Thank you for getting back to us.

Actually, RadComboBox behavior is consistent to the one of Microsoft ComboBox. When you type some text in RadComboBox or ComboBox, and if an item with such text exists, it will become the selected item (and the SelectedIndexChanged event will be fired) when you Tab off the control. I am attaching a sample project to demonstrate this.

If you have additional questions, feel free to contact me.

Sincerely yours,
Nikolay
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Toolstrip (obsolete as of Q3 2010)
Asked by
Loy Chan
Top achievements
Rank 1
Answers by
Loy Chan
Top achievements
Rank 1
Dimitar Kapitanov
Telerik team
Nikolay
Telerik team
Share this question
or