[Gtk-sharp-list] ComboBox
heat sink
heatxsink at gmail.com
Tue Jan 3 08:32:56 EST 2006
On 1/3/06, Evgeny Pirogov <pirogov.e at gmail.com> wrote:
>
> Hello. Happy New Year!
>
> I need simple example for Gtk.ComboBox usage as DropDownList (value only
> set from list, no write).
Check Monodoc I think what you are looking for should be in the sample code
in the overview section. It's also located in the web version of the
documentation at http://www.go-mono.com/docs/ under Gnome
Libraries->Gtk->ComboBox Class. Just in case you cannot access the web
documentation (but somehow able to read email...), or access/build Monodoc,
I've pasted the sample code from said documentation below...
using System;
using Gtk;
class ComboBoxSample
{
static void Main ()
{
new ComboBoxSample ();
}
ComboBoxSample ()
{
Application.Init ();
Window win = new Window ("ComboBoxSample");
win.DeleteEvent += new DeleteEventHandler (OnWinDelete);
ComboBox combo = ComboBox.NewText ();
for (int i = 0; i < 5; i ++)
combo.AppendText ("item " + i);
combo.Changed += new EventHandler (OnComboBoxChanged);
win.Add (combo);
win.ShowAll ();
Application.Run ();
}
void OnComboBoxChanged (object o, EventArgs args)
{
ComboBox combo = o as ComboBox;
if (o == null)
return;
TreeIter iter;
if (combo.GetActiveIter (out iter))
Console.WriteLine ((string) combo.Model.GetValue (iter, 0));
}
void OnWinDelete (object obj, DeleteEventArgs args)
{
Application.Quit ();
}
}
Thanks.
>
> _______________________________________________
> Gtk-sharp-list maillist - Gtk-sharp-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
>
>
>
Happy Hacking!
--
Nick Granado
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/gtk-sharp-list/attachments/20060103/d320ad61/attachment.html
More information about the Gtk-sharp-list
mailing list