How to set the value of a Gtk.ComboBox?

前端 未结 3 1223
醉话见心
醉话见心 2021-01-14 07:31

All I can figure out is something to do with the ComboBox.GetEnumerator or something like that.

I would like to do something like:

System.Collections         


        
3条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-14 07:59

    As an alternative you can set the "selected index" like this if you have the elements of the ComboBox stored in an Array or List

    for (int i = 0; i < combo.Model.IterNChildren(); ++i) //iterate over ComboBox elements
    {
      if (myList[i].Equals(elementToSelect))
      {
        combo.Active = i;
        break;
      }
    }
    

提交回复
热议问题