[Gtk-sharp-list] Drop-down list
blixtra at gmail.com
Thu Apr 13 06:49:08 EDT 2006
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:
It will show you how to setup a ListStore (The one-dimension version
of the TreeStore).
Hope that point you in the right direction.
On 4/13/06, Finn Gruwier Larsen <finn at gruwier.dk> wrote:
> Victor Rafael Rivarola Soerensen (FANATICO y LOCO por Cristo) skrev:
> > 2006/4/13, Finn Gruwier Larsen <finn at gruwier.dk <mailto:finn at gruwier.dk>>:
> > I need to make a simple drop-down list in my application. The list items
> > should corespond with an ArrayList of objects, and when the user
> > chooses an item, an object variable should be set to the object that
> > coresponds with the chosen list item.
> > I have tried to study the documentation for ComboBox, but I can't figure
> > out how to pair the ComboBox with my ArrayList.
> > System.Collections.ArrayList al;
> > string  ar [al.Count];
> > // Fill ar here somehow.
> > al.CopyTo (ar);
> > Gtk.ComboBox combo = new Gtk.ComboBox (ar);
> I can make the combo box and make it show the relevant information. But
> what will the comboChanged event handler look like? Note that I'm not
> interested in getting the text fra the combo, but getting the actual
> object: if item #2 i chosen from the combo, I want a reference to the
> 2.nd object in the ArrayList. Somehow I need to get the index number of
> the chosen item.
> Best regards,
> Finn G. Larsen
> Gtk-sharp-list maillist - Gtk-sharp-list at lists.ximian.com
More information about the Gtk-sharp-list