Reputation: 8027
How do I get the selected value (either the string, or an int reference) from a Gtk.ComboBox in mono? All I can find is stuff about using iterators. Why isn't there a function to simply fetch the value (or is there)?
Upvotes: 6
Views: 9086
Reputation: 661
to get the selected value in a GTK+ combo box I used:
TreeIter tree;
comboBox.GetActiveIter(out tree);
TreeModel = comboBox.Model ();
String selectedText = (String) comboBox.Model.GetValue (tree, 0);
"comboBox" is the GTK combo box. I hope this will help.
Upvotes: 4
Reputation: 47561
For (int) index you can use:
comboBox.Active;
and for text:
comboBox.ActiveText;
Upvotes: 7