gtk-sharp 0.0.0.0 Gtk# is thread aware, but not thread safe; See the Gtk# Thread Programming for details. A button that can be toggled on and off. A is a which will remain 'pressed-in' when clicked. Clicking again will cause the toggle button to return to it's normal state. This is useful if you need to maintain the state of a button. using Gtk; using GtkSharp; using System; public class ToggleButtonApp { ToggleButton btn; public static int Main (string[] args) { new ToggleButtonApp(); return 0; } public ToggleButtonApp() { Application.Init (); Window win = new Window ("ToggleButton Tester"); win.SetDefaultSize (200, 150); win.DeleteEvent += new DeleteEventHandler (Window_Delete); btn = new ToggleButton ("Unselected"); btn.Active = false; btn.Toggled += new EventHandler (btn_toggled); win.Add (btn); win.ShowAll (); Application.Run (); } void btn_toggled (object obj, EventArgs args) { Console.WriteLine ("Button Toggled"); if (btn.Active) { btn.Label = "Unselected"; } else { btn.Label = "Selected"; } } static void Window_Delete (object obj, DeleteEventArgs args) { Application.Quit (); args.RetVal = true; } } Gtk.Button Atk.Implementor GLib.IWrapper GLib.IWrapper System.IDisposable Method Gtk.ToggleButton Creates a new with a text label. a containing the message to be placed in the toggle button. a new . Creates a new with a text label. Method System.Void Emits the event Emits the event on the . There is no good reason for an application ever to call this function. Method System.Void Disposes the resources associated with the object. Constructor Internal constructor Pointer to the C object. An instance of , wrapping the C object. This is an internal constructor, and should not be used by user code. Constructor Creates a new object an object of type Creates a new , which is a . A widget should be packed inside the toggle button using . Label label = new Label(); ToggleButton btn = new ToggleButton (); btn.Add(label); Constructor Creates a new with a text label. a containing the message to be placed in the toggle button. an object of type ' Creates a new with a text label. ToggleButton btn = new ToggleButton ("ToggleButton"); Property System.UInt32 The for The for the Property System.Boolean The Mode of the an object of type an object of type The Mode of the Sets whether the button is displayed as a separate indicator and label. You can call this function on a or a with = to make the button look like a normal button This function only effects instances of classes like and that derive from , not instances of itself. Property System.Boolean Determines if the has an intermediate state. an object of type 'bool' an object of type If the user has selected a range of elements (such as some text or spreadsheet cells) that are affected by a toggle button, and the current values in that range are inconsistent, you may want to display the toggle in an "in between" state. This function turns on "in between" display. Normally you would turn off the inconsistent state again if the user toggles the toggle button. This has to be done manually, only affects visual appearance, it doesn't affect the semantics of the button. Property System.Boolean Get or set the active an object of type 'bool' an object of type Get or set the active. Get: Queries a and returns it's current state. Returns if the toggle button is pressed in and if it is raised. if (btn.Active) { Console.WriteLine("The ToggleButton is pressed in"); } else { Console.WriteLine("The ToggleButton is raised"); } Set: Sets the status of the toggle button. Set to if you want the GtkToggleButton to be 'pressed in', and to raise it. This action causes the toggled signal to be emitted. // set the togglebutton active // and appear "pressed in" btn.Active = true; Property System.Boolean Determines the drawing style of a or an object of type an object of type The DrawIndicator property can be set to to make or look like a normal . Event Triggered when the is clicked. Should be connected if you wish to perform an action whenever the 's state is changed. ToggleButton btn = new ToggleButton("ToggleButton"); btn.Toggled += new EventHandler (btn_toggled); void btn_toggled (object obj, EventArgs args) { // code for toggled event here } Constructor Internal constructor GLib type for the type Creates a new instance of , using the GLib-provided type This is a constructor used by derivative types of that would have their own assigned to it. This is not typically used by C# code.