From 62494b387b08de54082d055005e37085a98988f4 Mon Sep 17 00:00:00 2001 From: Lee Mallabone Date: Wed, 2 Apr 2003 08:30:07 +0000 Subject: [PATCH] Add an example to Viewport docs. svn path=/trunk/gtk-sharp/; revision=13022 --- doc/en/Gtk/Viewport.xml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/doc/en/Gtk/Viewport.xml b/doc/en/Gtk/Viewport.xml index e8395e2bf..66396ed7c 100644 --- a/doc/en/Gtk/Viewport.xml +++ b/doc/en/Gtk/Viewport.xml @@ -12,6 +12,25 @@ To scroll correctly, a ordinarily requires explicit support from the that will be scrolled. However, a Viewport adds scrolling capabilities to an arbitrary child widget. For example, you can add a collection of widgets to a container. By simply placing the in a Viewport, you need only add the Viewport to a to visually scroll the contents of your Table. The "model" of this widget consists of horizontal and vertical objects. These do not need to be explicitly set to use the Viewport. Packing a child widget as demonstrated in the example, below, is all that is required. The appearance of the Viewport can be adjusted using the property. + The following example creates a in a Viewport. When placed in a small , the widgets can be scrolled. + + +public ScrolledWindow CreateViewport() +{ + ScrolledWindow scroller = new ScrolledWindow(); + Viewport viewer = new Viewport(); + + // Create a table with text entries in it + Table widgets = new Table(1, 2, false); + widgets.Attach(new Entry("This is example Entry 1"), 0, 1, 0, 1); + widgets.Attach(new Entry("This is example Entry 2"), 1, 2, 0, 1); + + // Place the widgets in a Viewport, and the Viewport in a ScrolledWindow + viewer.Add(widgets); + scroller.Add(viewer); + return scroller; +} +