GrapeCity MultiRow Windows Forms Documentation
Scrolling

The GcMultiRow control allows you to display or hide the scroll bar, set the scroll unit, set the scroll amount, specify rendering at the time of scrolling, set scroll tips, and so on.

Show or Hide the Scroll Bar

You can hide or display the scroll bar using the ScrollBars property.

Using Code

The following code only displays vertical scroll bars.

[VB]

GcMultiRow1.ScrollBars = ScrollBars.Vertical

[CS]

gcMultiRow1.ScrollBars = ScrollBars.Vertical;

You can temporarily hide the scroll bar, for example, when the entire grid is displayed in the view.

If you use the GcMultiRow.HorizontalScrollBarMode property for the horizontal scroll bar, and GcMultiRow.VerticalScrollBarMode property for the vertical scroll bar, and set the respective properties to Automatic, the GcMultiRow control will display the scroll bar only when necessary.

Using Code

This example displays scroll bars when needed.

[VB]

GcMultiRow1.HorizontalScrollBarMode = GrapeCity.Win.MultiRow.ScrollBarMode.Automatic
GcMultiRow1.VerticalScrollBarMode = GrapeCity.Win.MultiRow.ScrollBarMode.Automatic

[CS]

gcMultiRow1.HorizontalScrollBarMode = GrapeCity.Win.MultiRow.ScrollBarMode.Automatic;
gcMultiRow1.VerticalScrollBarMode = GrapeCity.Win.MultiRow.ScrollBarMode.Automatic;
The user can still scroll the grid using the mouse if the grid's data exceeds the display range of the grid even when the scroll bar has been hidden.

Scrolling By Pixels

The GcMultiRow control is scrolled row by row by default. The vertical scrolling can be executed in pixels by setting the ScrollMode enumeration to Pixel. Horizontal scrolling is always executed in pixels.

Using Code

This example sets the ScrollMode property.

[VB]

GcMultiRow1.RowCount = 200
GcMultiRow1.ScrollMode = GrapeCity.Win.MultiRow.ScrollMode.Pixel

[CS]

gcMultiRow1.RowCount = 200;
gcMultiRow1.ScrollMode = GrapeCity.Win.MultiRow.ScrollMode.Pixel;

Changing the Scroll Count

The GcMultiRow.VerticalScrollCount and the GcMultiRow.HorizontalScrollCount properties can be used to modify how much area is moved in one scroll. Scrolling speed can be modified based on the template size or layout using these settings.

Using Code

The following code sets a single scroll count for vertical scrolling to 10 pixels.

[VB]

GcMultiRow1.RowCount = 200
GcMultiRow1.ScrollMode = GrapeCity.Win.MultiRow.ScrollMode.Pixel
GcMultiRow1.VerticalScrollCount = 10

[CS]

gcMultiRow1.RowCount = 200;
gcMultiRow1.ScrollMode = GrapeCity.Win.MultiRow.ScrollMode.Pixel;
gcMultiRow1.VerticalScrollCount = 10;

Use the GcMultiRow.MouseWheelCount property to modify the scroll count for vertical scrolling when using the mousewheel.

Scrolling using the tiltwheel of a mouse (for left-right scrolling) is not supported.

Suppress Grid Updates while Dragging the Scroll Bar

By default the GcMultiRow grid is updated as soon as the user scrolls the grid. For example, when the user is dragging a scroll bar, the data in the grid is updated in realtime with the position of the scroll bar. This behavior ensures a fast response; however, if the grid is bound to data, especially when using virtual mode, it may affect the performance. Grid updates can be suppressed while dragging is underway, and resumed after the dragging is complete, with the GcMultiRow.ScrollOnThumbTrack property. As a result, the load on the grid and the data source can be reduced.

Using Code

The following code allows the grid to be updated while the user is using the horizontal scroll bar. The grid is updated only after the dragging is complete if using the vertical scroll bar.

[VB]

GcMultiRow1.ScrollOnThumbTrack = GrapeCity.Win.MultiRow.ScrollOnThumbTrack.Horizontal

[CS]

gcMultiRow1.ScrollOnThumbTrack = GrapeCity.Win.MultiRow.ScrollOnThumbTrack.Horizontal;

ScrollTip

Use the GcMultiRow.ShowScrollTip property to display information about the row and cell in a tooltip while scrolling. If this property is set to Both, the scrolltips display the row number during vertical scrolling, and pixel position during horizontal scrolling. Control the display positions of the scrolltips using the GcMultiRow.VerticalScrollTipAlignment property for vertical scrolling and the GcMultiRow.HorizontalScrollTipAlignment property for horizontal scrolling. Scrolltip text can be set by using the ScrollTipTextNeeded event.

Using Code

The following code displays the index numbers of the scrolling destination cells in the form of tooltips while scrolling with the vertical and horizontal scroll bars.

[VB]

Imports GrapeCity.Win.MultiRow

Private Sub Form1_Load( _
    ByVal sender As System.Object, ByVal e As System.EventArgs _
    ) Handles MyBase.Load
    GcMultiRow1.RowCount = 200
    GcMultiRow1.ShowScrollTip = ScrollBars.Vertical
End Sub

Private Sub GcMultiRow1_ScrollTipTextNeeded( _
    ByVal sender As System.Object, ByVal e As ScrollTipTextNeededEventArgs _
    ) Handles GcMultiRow1.ScrollTipTextNeeded
    If e.Direction = Orientation.Vertical Then
        e.ScrollTipText = e.ScrollRowIndex
    End If
End Sub

[CS]

using GrapeCity.Win.MultiRow;

private void Form1_Load(object sender, EventArgs e)
{
    gcMultiRow1.RowCount = 200;
    gcMultiRow1.ShowScrollTip = ScrollBars.Vertical;
}

private void gcMultiRow1_ScrollTipTextNeeded(object sender, ScrollTipTextNeededEventArgs e)
{
    if (e.Direction == Orientation.Vertical)
        e.ScrollTipText = e.ScrollRowIndex.ToString();
}

Scroll Bar Styles

The scroll bar style can be modified using the GcMultiRow.ScrollBarStyle property. For details, refer to Visual Style.

Scrolling By Rows Using Code

The cell displayed at the top left of the grid can be specified using the GcMultiRow.FirstDisplayedCellPosition property.

Using Code

The following code scrolls the grid such that the first cell of the fifth row is displayed at the top left.

[VB]

GcMultiRow1.RowCount = 10
GcMultiRow1.FirstDisplayedCellPosition = New GrapeCity.Win.MultiRow.CellPosition(4, 0)

[CS]

gcMultiRow1.RowCount = 10;
gcMultiRow1.FirstDisplayedCellPosition = new GrapeCity.Win.MultiRow.CellPosition(4, 0);

Scrolling through Coordinates Using code

You can specify the coordinates to be displayed on the top left of the grid using the GcMultiRow.FirstDisplayedLocation property.

Using Code

This example sets the FirstDisplayedLocation property.

[VB]

GcMultiRow1.RowCount = 10
GcMultiRow1.FirstDisplayedLocation = New Point(200, 100)

[CS]

gcMultiRow1.RowCount = 10;
gcMultiRow1.FirstDisplayedLocation = new Point(200, 100);

Scrolling And Continuous Input Mode

Usually, the scrolling speed decreases when continuous input mode is active. This happens because the cells invariably transit into an editable state with movement. For details on continuous input mode, refer to Edit Modes.

See Also

 

 


Copyright © GrapeCity, inc. All rights reserved.

Support Options