Show / Hide Table of Contents

# Class ScrollView

Scrollviews are views that present a window into a virtual space where subviews are added. Similar to the iOS UIScrollView.

##### Inheritance

System.Object
Responder
View
ScrollView

##### Implements

System.Collections.IEnumerable

##### Inherited Members

View.Enter
View.Leave
View.MouseEnter
View.MouseLeave
View.MouseClick
View.Driver
View.Subviews
View.Id
View.IsCurrentTop
View.WantMousePositionReports
View.WantContinuousButtonPressed
View.Frame
View.GetEnumerator()
View.LayoutStyle
View.Bounds
View.X
View.Y
View.Width
View.Height
View.SuperView
View.SetNeedsDisplay()
View.SetNeedsDisplay(Rect)
View.ChildNeedsDisplay()
View.Add(View[])
View.Remove(View)
View.BringSubviewToFront(View)
View.SendSubviewToBack(View)
View.SendSubviewBackwards(View)
View.BringSubviewForward(View)
View.Clear()
View.Clear(Rect)
View.ScreenToView(Int32, Int32)
View.ClipToBounds()
View.SetClip(Rect)
View.DrawFrame(Rect, Int32, Boolean)
View.DrawHotString(ustring, Attribute, Attribute)
View.DrawHotString(ustring, Boolean, ColorScheme)
View.Move(Int32, Int32)
View.HasFocus
View.OnEnter()
View.OnLeave()
View.Focused
View.MostFocused
View.ColorScheme
View.AddRune(Int32, Int32, Rune)
View.ClearNeedsDisplay()
View.DrawContent
View.OnDrawContent(Rect)
View.SetFocus(View)
View.KeyPress
View.ProcessHotKey(KeyEvent)
View.ProcessColdKey(KeyEvent)
View.KeyDown
View.OnKeyDown(KeyEvent)
View.KeyUp
View.OnKeyUp(KeyEvent)
View.EnsureFocus()
View.FocusFirst()
View.FocusLast()
View.FocusPrev()
View.FocusNext()
View.LayoutComplete
View.LayoutSubviews()
View.ToString()
View.OnMouseEnter(MouseEvent)
View.OnMouseLeave(MouseEvent)
View.OnMouseEvent(MouseEvent)
Responder.CanFocus
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)

###### Namespace: Terminal.Gui

###### Assembly: Terminal.Gui.dll

##### Syntax

    public class ScrollView : View, IEnumerable

##### Remarks

The subviews that are added to this ScrollView are offset by the ContentOffset property. The view itself is a window into the space represented by the ContentSize.

Use the

### Constructors

#### ScrollView()

Initializes a new instance of the ScrollView class using Computed positioning.

##### Declaration

    public ScrollView()

#### ScrollView(Rect)

Initializes a new instance of the ScrollView class using Absolute positioning.

##### Declaration

    public ScrollView(Rect frame)

##### Parameters

Type | Name | Description
--- | --- | ---
Rect | frame |

### Properties

#### ContentOffset

Represents the top left corner coordinate that is displayed by the scrollview

##### Declaration

    public Point ContentOffset { get; set; }

##### Property Value

Type | Description
--- | ---
Point | The content offset.

#### ContentSize

Represents the contents of the data shown inside the scrolview

##### Declaration

    public Size ContentSize { get; set; }

##### Property Value

Type | Description
--- | ---
Size | The size of the content.

#### ShowHorizontalScrollIndicator

Gets or sets the visibility for the horizontal scroll indicator.

##### Declaration

    public bool ShowHorizontalScrollIndicator { get; set; }

##### Property Value

Type | Description
--- | ---
System.Boolean | `true` if show vertical scroll indicator; otherwise, `false`.

#### ShowVerticalScrollIndicator

/// Gets or sets the visibility for the vertical scroll indicator.

##### Declaration

    public bool ShowVerticalScrollIndicator { get; set; }

##### Property Value

Type | Description
--- | ---
System.Boolean | `true` if show vertical scroll indicator; otherwise, `false`.

### Methods

#### Add(View)

Adds the view to the scrollview.

##### Declaration

    public override void Add(View view)

##### Parameters

Type | Name | Description
--- | --- | ---
View | view | The view to add to the scrollview.

##### Overrides

View.Add(View)

#### MouseEvent(MouseEvent)

Method invoked when a mouse event is generated

##### Declaration

    public override bool MouseEvent(MouseEvent me)

##### Parameters

Type | Name | Description
--- | --- | ---
MouseEvent | me |

##### Returns

Type | Description
--- | ---
System.Boolean | `true`, if the event was handled, `false` otherwise.

##### Overrides

Responder.MouseEvent(MouseEvent)

#### PositionCursor()

Positions the cursor in the right position based on the currently focused view in the chain.

##### Declaration

    public override void PositionCursor()

##### Overrides

View.PositionCursor()

#### ProcessKey(KeyEvent)

If the view is focused, gives the view a chance to process the keystroke.

##### Declaration

    public override bool ProcessKey(KeyEvent kb)

##### Parameters

Type | Name | Description
--- | --- | ---
KeyEvent | kb |

##### Returns

Type | Description
--- | ---
System.Boolean |

##### Overrides

View.ProcessKey(KeyEvent)

##### Remarks

Views can override this method if they are interested in processing the given keystroke. If they consume the keystroke, they must return true to stop the keystroke from being processed by other widgets or consumed by the widget engine. If they return false, the keystroke will be passed using the ProcessColdKey method to other views to process.

The View implementation does nothing but return false, so it is not necessary to call base.ProcessKey if you derive directly from View, but you should if you derive other View subclasses.

#### Redraw(Rect)

Redraws this view and its subviews; only redraws the views that have been flagged for a re-display.

##### Declaration

    public override void Redraw(Rect region)

##### Parameters

Type | Name | Description
--- | --- | ---
Rect | region |

##### Overrides

View.Redraw(Rect)

##### Remarks

Always use Bounds (view-relative) when calling Redraw(Rect), NOT Frame (superview-relative).

Views should set the color that they want to use on entry, as otherwise this will inherit the last color that was set globaly on the driver.

Overrides of Redraw(Rect) must ensure they do not set `Driver.Clip` to a clip region larger than the `region` parameter.

#### RemoveAll()

Removes all widgets from this container.

##### Declaration

    public override void RemoveAll()

##### Overrides

View.RemoveAll()

##### Remarks

#### ScrollDown(Int32)

Scrolls the view down.

##### Declaration

    public bool ScrollDown(int lines)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Int32 | lines | Number of lines to scroll.

##### Returns

Type | Description
--- | ---
System.Boolean | `true`, if left was scrolled, `false` otherwise.

#### ScrollLeft(Int32)

Scrolls the view to the left

##### Declaration

    public bool ScrollLeft(int cols)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Int32 | cols | Number of columns to scroll by.

##### Returns

Type | Description
--- | ---
System.Boolean | `true`, if left was scrolled, `false` otherwise.

#### ScrollRight(Int32)

Scrolls the view to the right.

##### Declaration

    public bool ScrollRight(int cols)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Int32 | cols | Number of columns to scroll by.

##### Returns

Type | Description
--- | ---
System.Boolean | `true`, if right was scrolled, `false` otherwise.

#### ScrollUp(Int32)

Scrolls the view up.

##### Declaration

    public bool ScrollUp(int lines)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Int32 | lines | Number of lines to scroll.

##### Returns

Type | Description
--- | ---
System.Boolean | `true`, if left was scrolled, `false` otherwise.

### Implements

System.Collections.IEnumerable