[Gtk-sharp-list] Help with GTK sharp

Dan Smithers dsmithers at talktalk.net
Wed Feb 13 10:35:18 EST 2008


Thanks Vlad, I've got it working now.

Is there a way of combining multiple columns on a ComboBox? I can do it
with a TreeView without the dropdown aspect of a combo. Or when I do it
on a combo, I get the second column in the drop down and the first in
the permanent display.

I want to display an integer value, with some explanatory text.

Gtk.ComboBox combobox = Gtk.ComboBox.NewText();
Gtk.CellRendererText cell = new Gtk.CellRendererText();
combobox.PackStart(cell, true);
combobox.AddAttribute(cell, "text", 0);
combobox.AddAttribute(cell, "text", 1);

Gtk.ListStore store = new Gtk.ListStore(typeof(int), typeof(string));
combobox.Model = store;

for (int i = 0; i < 4; ++i)
{
  store.AppendValues(i, "item "+i.Tostring());
}

GtkTreeIter iter;
combobox.Model.GetIterFirst(out iter);
combobox.Model.SetActiveIter(iter);


Vladimir Giszpenc wrote:
> Dan,
> 
> Here is how I set a default:
> 
> 			ListStore store = new ListStore(typeof (string));
> 			this.cboLogLevel.Model = store;
> 			TreeIter iter = store.AppendValues(LogLevel.Debug.ToString());
> 			this.cboLogLevel.SetActiveIter(iter);
> 
> Vlad
> 


More information about the Gtk-sharp-list mailing list