How to reset ComboBox to initial state (clear the display)

Hi, I thought if I set the SelectedIndex of the SfComboBox to -1 it would clear the display. That is not working for me. So, how can I do that? Thanks!

3 Replies 1 reply marked as answer

SS Suganya Sethuraman Syncfusion Team October 9, 2020 05:42 AM UTC

Hi Will,

Greetings from Syncfusion.

We have analyzed your query. The selected value of SfComboBox has been cleared externally by using any of the following solutions,

            By setting the null value to the SelectedItem property.
 
            By calling the SfComboBox Clear method.

Code Snippet:
 
        private void Button_Clicked(object sender, EventArgs e) 
        { 
           // employeeViewModel.SelectedItem = null; 
         //(or) 
          comboBox.Clear(); 
        } 

Please have the sample for your reference,

Sample:  https://www.syncfusion.com/downloads/support/directtrac/general/ze/ComboBoxSelectedValue1350906669

Please check the sample if it meets your requirements and let us know if you have any concerns.

Regards,
Suganya Sethuraman.
 


Marked as answer

WA Will Autio October 9, 2020 04:07 PM UTC

Works great - thanks a lot!


SS Suganya Sethuraman Syncfusion Team October 12, 2020 04:36 AM UTC

Hi Will,

Thanks for the update.

We are glad to know that the given solution works. Please let us know if you need any further assistance.

Regards,
Suganya Sethuraman.
 


Loader.
Up arrow icon