How do I clear a combobox?

前端 未结 16 1750
醉梦人生
醉梦人生 2020-12-04 18:55

I have some combo-boxes that are set up as drop down lists, and the user can pick a number in them. I also have a Clear button that should clear the text from the combo boxe

相关标签:
16条回答
  • 2020-12-04 19:43

    Answer for your question is:

    metroComboBox1.SelectedItem = null;
    anycomboBox1.SelectedItem=null;
    
    0 讨论(0)
  • 2020-12-04 19:43

    In WPF You can try this code

    cbHours.Items.Clear();

    0 讨论(0)
  • 2020-12-04 19:45

    If you have applied datasource to combobox, then it will not be cleared as cmb.Items.Clear().

    For that you have to assign datasource null to combobox.

    cmb.DataSource = null;
    cmb.Items.Clear();
    
    0 讨论(0)
  • 2020-12-04 19:48

    Did you try cboxHour.Items.Clear()?

    0 讨论(0)
提交回复
热议问题