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

Clear Selection

4 Answers 423 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Lee
Top achievements
Rank 1
Lee asked on 04 Oct 2012, 07:19 PM
I have placed a radlistbox in a dropdown button.  I have SelectionMode = Single.  I have an event handler for the selectionchanged to know which item they selected.  In that handler I set the dropdown button to close, get the item and clear the selection.  I do this so that the next time the user opens the menu there is not an item selected in the listbox.  I have tried 3 different things but the highlight of the item does not go away.  I have tried:

SelectedItems.Clear();
SelectedItem = null;
SelectedIndex = -1;

As previously stated, none of these clear the UI selection.  The SelectedItem property is set to null, but all previously clicked on items are still highlighted in the UI.

Thanks in advance,
Lee

4 Answers, 1 is accepted

Sort by
0
Lee
Top achievements
Rank 1
answered on 04 Oct 2012, 07:40 PM
What I am looking for is the equivalent to UnselectAll() that is on the windows version of this control.
0
Georgi
Telerik team
answered on 09 Oct 2012, 02:06 PM
Hi Lee,

The reason behind this issue is that  by design the RadListBox does not expect to change the selection in the SelectionChanged event (this could trigger another SelectionChanged event). So what you can do is clear the selection when closing the DropdownButton.
Attached you can find an example of that, it would be great if you can give it a try and let us know if this works for you.

Kind regards,
Georgi
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Lee
Top achievements
Rank 1
answered on 10 Oct 2012, 04:38 PM
Your sample project shows the problem exactly.  Run your sample project and select item #2 in the list.  Now click the dropdown button.  You will see that item #2 is still highlighted and if you select it, then the radListBox_SelectionChanged is not fired.  Therefore, the selection is not being released.

Please advise.
0
Georgi
Telerik team
answered on 15 Oct 2012, 12:11 PM
Hi Lee,

I am attaching video showing how it behaves using 2012.2.912 version of the controls, also I have slightly modified the project so the SelectedItem of the ListBox can be shown. Can you confirm that we are using the same version of the controls or if we differ in something else?

Regards,
Georgi
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
ListBox
Asked by
Lee
Top achievements
Rank 1
Answers by
Lee
Top achievements
Rank 1
Georgi
Telerik team
Share this question
or