[Gtk-sharp-list] How to clear combobox (easy way if possible)?
cdhowie at gmail.com
Sun Dec 6 16:43:25 EST 2009
On Sun, Dec 6, 2009 at 9:07 AM, macias <bluedzins at wp.pl> wrote:
> I populate combobox items at runtime using AppendText method. I also would
> like to to clear combobox (remove all entries added previously). However I
> cannot find anything appropriate. I also cannot find out how many entries
> there are -- if I could I would use RemoveText method (currently I simply
> run for loop with such big limit that I know in advance there won't be so
> many items, I know, very ugly workaround and buggy).
> I found relevant post here:
> (search for combobox section), however I don't have such method as Clear.
> Another post here:
> but Model also does not have such method as Clear.
> So, again -- how to clear combobox? Superficially it should easy task.
> Thank you in advance for help.
If you are going to be doing anything but simple add/remove operations
on your ComboBox's entries, then you should instead use your own
model, since the base TreeModel interface is read-only. Look at
creating a ListStore (new ListStore(typeof(string))). That model
should give you all the methods you need to do what you want.
More information about the Gtk-sharp-list