[Gtk-sharp-list] Using RadioButtons
Jeremiah McElroy
jeremiah@facility9.com
Mon, 08 Mar 2004 10:55:06 -0500
Thanks,
I was also looking for an example of how to check with RadioButton in a
group is checked. In SWF you just examine the checked property of the
RadioButton, but I can't seem to find that in the monodocs and I was
wondering if there was a different property that I should be checking.
Again, thanks,
Jeremiah
Antonio Martínez Álvarez wrote:
> Jeremiah McElroy wrote:
>
>> I have an app with a Gtk.Dialog that contains a group of
>> RadioButtons. I would like to use the radio buttons to set a user
>> preference in the application. I can't seem to find any examples (in
>> either MS or Mono docs) about how to do this. If anyone has an
>> example or advice, I would greatly appreciate it.
>
>
> This example works for me. I don't know if this is very correct, but
> it works:
>
> using System;
> using Gtk;
> using GtkSharp;
> class Capp {
> Gtk.Window win;
> RadioButton rb1,rb2,rb3;
> Table t;
> Capp() {
> win = new Gtk.Window("Trest");
> win.DeleteEvent += new DeleteEventHandler(Quit);
> t = new Table(3,1, true);
> rb1 = new RadioButton(null, "RB 1");
> rb2 = new RadioButton(null, "RB 2");
> rb3 = new RadioButton(null, "RB 3");
> rb2.Group = rb1.Group;
> rb3.Group = rb1.Group;
> t.Attach(rb1,0,1,0,1);
> t.Attach(rb2,0,1,1,2);
> t.Attach(rb3,0,1,2,3);
> win.Add(t);
> win.ShowAll();
> }
> static void Main() {
> Application.Init();
> Capp win = new Capp();
> Application.Run();
> }
> void Quit(object o, DeleteEventArgs a) {
> Application.Quit();
> }
> }