[Gtk-sharp-list] Gtk.ComboBox?

Paulo Pires paulo.pires@vodafone.pt
Wed, 05 Jan 2005 11:47:44 +0000


S=C3=A1b, 2004-12-18 =C3=A0s 09:54 -0600, Sergio Duran escreveu:

> This is a small example I can think of. Feel free to correct me if I
> do something wrong, anyone, I know I'm not the best :)
>=20
> ComboBox combo =3D new ComboBox();
> // I use a name and an invisible ID
> ListStore store =3D new Store(typeof(string), typeof(int));=20
> CellRendererText text =3D new CellRendererText();
> combo.PackStart(text, false);
> combo.AddAttribute(text, "text", 0);
>=20
> TreeIter iter;
> iter =3D store.AppendValues("-- Select", 0);
> combo.SetActiveIter(iter);
> store.AppendValues("Item 1", 1);
> store.AppendValues("Item 90", 90);

ListStore store =3D new Store() ????
Do you get your ComboBox populated?! I don't know how!

This is kinda wrong, at least following my mono-1.1.3 compiler.
This example won't even compile, so I decided to get my hand on it. Here
it is:

// Begin ComboBox
ComboBox combo =3D new ComboBox();
ListStore store =3D new ListStore(typeof(string));=20
CellRendererText text =3D new CellRendererText();
combo.PackStart(text, false);
combo.AddAttribute(text, "text", 0);
combo.Model =3D store;

TreeIter iter;
iter =3D store.AppendValues("-- Select Item");
combo.SetActiveIter(iter); // this will make the default item on the
ComboBox at the current iter value
store.AppendValues("Item 1");
store.AppendValues("Item 90");
// End ComboBox


Paulo Pires