Gtk.Button Class
A widget that creates a signal when clicked on.

See Also: Button Members

Syntax

public class Button : Bin

Remarks

The Gtk.Button widget is generally used to attach to a function that is called when the button is pressed. The Gtk.Button widget can hold any valid child widget. That is, it can hold most any other standard Gtk.Widget. The most commonly used child is the Gtk.Label.

C# Example

using Gtk;
using System;
	
public class ButtonApp  {

	public static int Main (string[] args)
	{
		Application.Init ();
		Window win = new Window ("Button Tester");
		win.SetDefaultSize (200, 150);
		win.DeleteEvent += new DeleteEventHandler (Window_Delete);
		Button btn = new Button ("Click Me");
		btn.Clicked += new EventHandler (btn_click);
		win.Add (btn);
		win.ShowAll ();
		Application.Run ();
		return 0;
	}

	static void btn_click (object obj, EventArgs args)
	{
		Console.WriteLine ("Button Clicked");
	}

	static void Window_Delete (object obj, DeleteEventArgs args)
	{
		Application.Quit ();
		args.RetVal = true;
	}

}
				

Requirements

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