MultiRow Windows Forms > Developer's Guide > Using MultiRow > Grid > 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.
You can hide or display the scroll bar using the ScrollBars property.
The following code only displays vertical scroll bars.
GcMultiRow1.ScrollBars = ScrollBars.Vertical |
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.
This example displays scroll bars when needed.
GcMultiRow1.HorizontalScrollBarMode = GrapeCity.Win.MultiRow.ScrollBarMode.Automatic GcMultiRow1.VerticalScrollBarMode = GrapeCity.Win.MultiRow.ScrollBarMode.Automatic |
gcMultiRow1.HorizontalScrollBarMode = 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. |
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.
This example sets the ScrollMode property.
GcMultiRow1.RowCount = 200 GcMultiRow1.ScrollMode = GrapeCity.Win.MultiRow.ScrollMode.Pixel |
gcMultiRow1.RowCount = 200; gcMultiRow1.ScrollMode = GrapeCity.Win.MultiRow.ScrollMode.Pixel; |
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.
The following code sets a single scroll count for vertical scrolling to 10 pixels.
GcMultiRow1.RowCount = 200 GcMultiRow1.ScrollMode = GrapeCity.Win.MultiRow.ScrollMode.Pixel GcMultiRow1.VerticalScrollCount = 10 |
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. |
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.
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.
GcMultiRow1.ScrollOnThumbTrack = GrapeCity.Win.MultiRow.ScrollOnThumbTrack.Horizontal |
gcMultiRow1.ScrollOnThumbTrack = GrapeCity.Win.MultiRow.ScrollOnThumbTrack.Horizontal; |
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.
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.
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 |
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(); } |
The scroll bar style can be modified using the GcMultiRow.ScrollBarStyle property. For details, refer to Visual Style.
The cell displayed at the top left of the grid can be specified using the GcMultiRow.FirstDisplayedCellPosition property.
The following code scrolls the grid such that the first cell of the fifth row is displayed at the top left.
GcMultiRow1.RowCount = 10 GcMultiRow1.FirstDisplayedCellPosition = New GrapeCity.Win.MultiRow.CellPosition(4, 0) |
gcMultiRow1.RowCount = 10; gcMultiRow1.FirstDisplayedCellPosition = new GrapeCity.Win.MultiRow.CellPosition(4, 0); |
You can specify the coordinates to be displayed on the top left of the grid using the GcMultiRow.FirstDisplayedLocation property.
This example sets the FirstDisplayedLocation property.
GcMultiRow1.RowCount = 10 GcMultiRow1.FirstDisplayedLocation = New Point(200, 100) |
gcMultiRow1.RowCount = 10; gcMultiRow1.FirstDisplayedLocation = new Point(200, 100); |
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.