kylejan
kylejan

Reputation: 163

wpf comboBox set selectedindex -1 but still show previous text

First, i select one item on the comboBox when the application is running.

Then i make some operations and after that i set the comboBox's selectedIndex -1 in the code. Actually, the comboBox's selectedItem is null now but it still displays the previous text on the UI. How can I fix that?

Upvotes: 0

Views: 250

Answers (1)

Nick Prozee
Nick Prozee

Reputation: 2913


You Should use:

comboBox.Items.Clear();

Explanation

It is a Bad practice setting your comboBox to a null selected Item. You should always (if possible) try to use microsoft standard functionality for these kind of actions.
It is more readable in this matter and safer to use.

Upvotes: 1

Related Questions