[Gtk-sharp-list] Add data to ComboBox
Ryan
rthomp@sympatico.ca
Tue, 23 Nov 2004 03:03:47 -0500
Dan Winship wrote:
>On Mon, 2004-11-22 at 06:54 -0500, Ryan wrote:
>
>
>>Just a few questions on Gtk.ComboBox in gtk-sharp 1.9.0.
>>
>>How do you add data to it?
>>
>>
>
>You need to create a TreeModel and either create the ComboBox with the
>TreeModel constructor, or set its Model property after creating it. Then
>you add things to the TreeModel, and they show up in the ComboBox. Note
>that I'm pretty sure that using TreeModel is currently really annoying,
>but Mike is working on that (but he's on vacation this week, so don't
>expect any progress until next week).
>
>
>
>>And lastly - does it support being populated by an ArrayList?
>>
>>
>
>Not in the current system. Possibly eventually.
>
>-- Dan
>
>
>_______________________________________________
>Gtk-sharp-list maillist - Gtk-sharp-list@lists.ximian.com
>http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
>
>
>
I started grasping the idea that it was using the TreeModel Interface
but I currently don't understand interfaces all that well. I managed to
get a little bit further thanks to your reply. I'm not getting the rows
but they're empty. I know that items to be added are getting passed to
the AppendValues method but they're aren't showing up. I'm assuming this
has to do with something along the lines of the TreeView.AppendColumn
but the ComboBox widget doesn't have something similiar (at least I
can't find it). Does this have to do with the TreeModel interface?
This is the similar code to what I have minus other junk that's being done.
What am I missing?
typesSelect = new ComboBox(model);
TreeStore typesStore = new TreeStore(typeof(string));
string [] types = userAccount.GetTypes();
typesSelect.Model = typesStore;
for(int i = 0; i < types.Length; i++)
{
Console.WriteLine(types[i]);
TreeIter iter = typesStore.AppendValues(types[i]);
}
Thanks for all your help. I've been at this for two days off and on and
it's driving me nuts.
RT