[Gtk-sharp-list] ComboBox with multiple Columns

Andy York andy at brdstudio.net
Fri Feb 19 07:08:25 EST 2010

I think this is what your are after:

                 Gtk.ListStore lsTest = new ListStore(typeof(int), 
typeof(string), typeof(string);
                 Gtk.ComboBox cboText = new Gtk.ComboBox();
                 Gtk.CellRendererText ct = new Gtk.CellRendererText();
                 Gtk.CellRendererText ct2 = new Gtk.CellRendererText();
                 cboText.PackStart(ct, false);
                 cboText.AddAttribute(ct, "text", 0);
                 cboText.AddAttribute(ct2, "text", 1);
                 cboText.Model = lsTest;
                 lsTest.AppendValues(1, "Row One", "Extra");
                 lsTest.AppendValues(2, "Row Two", "Extra 2");

This would display the 1nd and 2rd columns of the list store while 
making the 3rd column easily accessable by getting the GetActiveIter. If 
you're adding text via Stetic I don't know of anyway to gain access to 
additional data, I think you have to use a ListStore.

I hope I understood the question right, if not I'll try again.


On 2/19/2010 6:37 AM, Elmar Haneke wrote:
> Hi, I do have some problem in display of an GtkComboBox showing several
> columns (the first with data to select, additional with more information
> about each item).
> The Problem is that data is not aligned to columns - each cell does have
> a different width.
> How can I change that?
> Elmar
> _______________________________________________
> Gtk-sharp-list maillist  -  Gtk-sharp-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 8.5.435 / Virus Database: 271.1.1/2697 - Release Date: 02/19/10 07:34:00
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/gtk-sharp-list/attachments/20100219/53ea82fc/attachment.html 

More information about the Gtk-sharp-list mailing list