Gtk.ComboBox Class
A widget used to choose from a list of items.

See Also: ComboBox Members

Syntax

public class ComboBox : Bin, CellEditable, CellLayout

Remarks

C# Example

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 ();
	}
}
  

Requirements

Namespace: Gtk
Assembly: gtk-sharp (in gtk-sharp.dll)
Assembly Versions: 2.12.0.0
Since: Gtk# 2.4