[Gtk-sharp-list] Dynamically inserting widgets

JimD Jim at keeliegirl.dyndns.org
Sun Jun 25 10:50:31 EDT 2006


Michael Hutchinson wrote:
> On 6/24/06, JimD <Jim at keeliegirl.dyndns.org> wrote:
>> Michael Hutchinson wrote:
>> > There's also the ReorderChild method, or you you could use some other
>> > widget (e.g. a label) as a placeholder.
>>
>> What method would I use to replace the label widget with some other 
>> widget?
> 
> There's no method to do it directly, but it's not hard to write one,
> e.g. (untested)
> 
> static void ReplaceWidget (Gtk.Widget old, Gtk.Widget new, Gtk.Box box)
> {
>    int pos = System.Array.IndexOf (box.Children, old);
>    if (pos < 0)
>        return;
> 
>    bool expand, fill;
>    uint packing;
>    Gtk.PackType packType;
>    box.QueryChildPacking (old, out expand, out fill, out padding, out
> packType);
> 
>    box.Remove (old);
>    box.PackEnd (new);
>    box.SetChildPacking (new, expand, fill, padding, packType);
>    box.ReorderChild (new, pos);
> 
>    new.Show ();
>    old.Destroy ();
> }
> 
> Alternatively you could use a Bin-derived container (i.e. contains
> only one object) as the placeholder, but that would be unnecessary
> overhead.
> 


Thanks for the directions.


Jim
-- 
         _\|/_
         (o o)
+----oOO-{_}-OOo-------------------------+
|  You roll an 18 in Dex and see if you  |
|  don't end up with a girlfriend        |
|  JimD - Central FL, USA, Earth, Sol    |
+----------------------------------------+


More information about the Gtk-sharp-list mailing list