[Gtk-sharp-list] ScrolledWindow and Label doesn't work

Peter Johanson peter at peterjohanson.com
Tue Nov 16 08:31:07 EST 2010


Agro,

Change your line to:

sw.AddWithViewPort(lbl);

and it *should* work. Gtk.Label itself does not support scrolling, so by
calling AddWithViewPort, this adds the Gtk.Label inside of a
Gtk.Viewport and then adds the Viewport to the ScrolledWindow. The
Viewport widget then handles the scrolling functionality for the
contained widget.

-pete

On Tue, Nov 16, 2010 at 01:46:42PM +0900, Agro Rachmatullah wrote:
> I tried to put a Label inside a ScrolledWindow, but the scrollbar
> wouldn't appear no matter what. What am I doing wrong? My code is
> below:
> 
> //////////////////////////////////////// code start
> 
> using System;
> using Gtk;
> 
> class SampleScrollBar : Gtk.Window
> {
>     public SampleScrollBar()
>     {
>         ScrolledWindow sw = new ScrolledWindow();
>         sw.SetPolicy(PolicyType.Automatic, PolicyType.Automatic);
>         this.Add(sw);
> 
>         Label lbl = new Label("This is a very long text. This is a
> very long text. This is a very long text. This is a very long text.");
>         sw.Add(lbl);
> 
>         this.DeleteEvent += delegate(object sender, DeleteEventArgs e)
>         {
>             Application.Quit();
>         };
>     }
> }
> 
> class Start
> {
>     static void Main()
>     {
>         Application.Init();
> 
>         var window = new SampleScrollBar();
> 
>         window.ShowAll();
>         Application.Run();
>     }
> }
> 
> //////////////////////////////////////// code end
> _______________________________________________
> Gtk-sharp-list maillist  -  Gtk-sharp-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
> 

-- 



More information about the Gtk-sharp-list mailing list