[Gtk-sharp-list] Drop-down list

Finn Gruwier Larsen finn at gruwier.dk
Thu Apr 13 08:57:38 EDT 2006


Chris Wilson skrev:
> You probably want attach a ListStore to the ComboBox' Model. The gives
> you a way to attach a list store with 2 columns to the ComboBox: one
> for an index into your ArrayList and the other to display.  You can
> then get the active row and use the index column in the ListView to
> get into the Array.
> 
> Take a look at the tutorial for using the TreeView at:
> http://www.mono-project.com/GtkSharp_TreeView_Tutorial
> 
> It will show you how to setup a ListStore (The one-dimension version
> of the TreeStore).
> 
> Hope that point you in the right direction.

I think I'm beginning to get it.

I have this:

//I need objects of class Address, so I make a ListStore
// with two "columns": one containing the text, one containg the object
ListStore ls = new ListStore(typeof(string), typeof(Address));

//I need to fetch the objects from the ArrayList currentUnit.Addresses
foreach(Address a in currentUnit.Addresses)
{	
	ls.AppendValues(a.ToString(), a);
}

The problem now is that the combo does not display anything. I think 
what I need now a way to "tell" the combo that the values to display are 
in the first "column".

Regards,

Finn Gruwier Larsen


More information about the Gtk-sharp-list mailing list