[MonoDevelop] Loop through all the controls on the active form in Gtk#?

Jon Cosby jon at jcosby.com
Tue Oct 30 19:51:03 EDT 2007


Ruben Guinez wrote:
> How I can do that?.
> In C#, but in Windows Forms .Net Window I can to do that. But with in
> Gtk# not yet !.
> 
> Please, Can anybody help me?
> 
> Thanks in advance...
> 

GTK# widgets are children to their containers. You have to iterate
through each container.


    Gtk.Widget[] widgets1 = this.vbox1.Children;
    Gtk.Widget[] widgets2;
    foreach(Widget w1 in widgets1)
    {
        if (w1 is Gtk.HButtonBox)
        {
            HButtonBox hbbox = (HButtonBox) w1;
            widgets2 = hbbox.Children;
            foreach (Widget w2 in widgets2)
            {
                Button btn = (Button) w2;
                btn.Label = "Hello";
            }
        }
    }



Jon Cosby


More information about the Monodevelop-list mailing list