[Gtk-sharp-list] ScrolledWindow and Label doesn't work
Michael Hutchinson
m.j.hutchinson at gmail.com
Wed Nov 17 01:29:21 EST 2010
On Mon, Nov 15, 2010 at 11:46 PM, Agro Rachmatullah <agro1986 at gmail.com> 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);
ScrolledWindow can only scroll scrollable widgets, such as TextView
and TreeView. For widgets that are not scrollable, you can put them
into a Viewport container. You can either create and add the Viewport
explicitly, then add the label to the Viewport, or use the
AddWithViewport convenience method.
sw.AddWithViewport (lbl);
For more info, see http://library.gnome.org/devel/gtk/stable/GtkViewport.html
--
Michael Hutchinson
http://mjhutchinson.com
More information about the Gtk-sharp-list
mailing list