Spread Windows Forms 11.0 Product Documentation
Customizing the Scroll Bars of the Component
Spread Windows Forms 11.0 Product Documentation > Developer's Guide > Customizing Sheet Interaction > Customizing Interaction with the Overall Component > Customizing the Scroll Bars of the Component

You can customize the display and operation of the scroll bars on the spreadsheet. There are several aspects of the display of scroll bars that you can specify. The parts of the scroll bars are shown in the following figure.

Scroll Bar Parts Shown

One way to customize the scroll bar display and operation is to use the EnhancedScrollBarRenderer class members.

Another way is to set these customizations to the scroll bars for the entire component using the properties in the FpSpread class. To set the scroll bars for the viewports, use the properties in the SpreadView class. The table below links to properties in the FpSpread class.

Customization Property in FpSpread

When to display either a vertical or horizontal scroll bar or both on the edges of the sheet in the component

HorizontalScrollBarPolicy

VerticalScrollBarPolicy

Dimensions of the scroll bars

HorizontalScrollBarHeight

VerticalScrollBarWidth

Whether the spreadsheet scrolls across the display when the user moves the scroll box (tracking)

ScrollBarTrackPolicy

Whether scroll bars are based on only the area that has data or on the entire spreadsheet

ScrollBarShowMax

Whether to align the scroll bars with the last row and column

ScrollBarMaxAlign

Whether scroll bar tips are displayed

See Customizing Scroll Bar Tips

If you want to set the width of a horizontal scroll bar, you can change the tab strip ratio, which determines the width of the tab strip, but also determines the width of the scroll bar. By default, the TabStripRatio property is set to 0.50 (area is divided 50% tab strip and 50% scroll bar). To increase the width of the scroll bar, for example, you could change the tab strip ratio to 0.25, which would divide the area between 25% for the tab strip and 75% for the scroll bar. For more information on customizing the tab strip, refer to Customizing the Sheet Name Tabs of the Component.

There are two events that indicate that the end user has moved the scroll bars. The TopChange event is raised when the end user moves the vertical scroll bar. The LeftChange event is raised when the horizontal scroll bar is moved. There is no event raised to indicate that the user has resized the tab strip.

The scroll bars are controls and so inherit the benefits of those controls. For example, there are context menus available on both the horizontal and vertical scroll bars that are available by default.

The default scroll bars do not display the page, home, or end arrows.

Smooth Scrolling

You can provide smooth scrolling with the VerticalScrollBarMode and HorizontalScrollBarMode properties.

Using the Properties Window

  1. At design time, in the Properties window, select the Spread component.
  2. Select (in the Behavior category) each of the scroll bar properties and set the values accordingly.
  3. Repeat for each property.

Using Code

To set the scroll bars for the component, set the FpSpread component scroll bar properties.

Example

This example creates a new Spread control on the form and specifies several aspects of the scroll bars for the component. Scroll bars appear larger than the default size. For scrolling horizontally, the spreadsheet scrolls as you move the scroll box; for scrolling vertically, the scroll bar tip shows the row number, but the spreadsheet does not scroll until you are done.

C#
Copy Code
FarPoint.Win.Spread.FpSpread fpSpread1 = new FarPoint.Win.Spread.FpSpread();
FarPoint.Win.Spread.SheetView shv = new FarPoint.Win.Spread.SheetView();
fpSpread1.Location = new Point(10, 10);
fpSpread1.Height = 250;
fpSpread1.Width = 400;
Controls.Add(fpSpread1);
fpSpread1.Sheets.Add(shv);
fpSpread1.HorizontalScrollBarPolicy = FarPoint.Win.Spread.ScrollBarPolicy.Always;
fpSpread1.VerticalScrollBarPolicy = FarPoint.Win.Spread.ScrollBarPolicy.AsNeeded;
fpSpread1.HorizontalScrollBarHeight = 30;
fpSpread1.VerticalScrollBarWidth = 30;
fpSpread1.ScrollBarMaxAlign = true;
fpSpread1.ScrollBarShowMax = true;
fpSpread1.ScrollBarTrackPolicy = FarPoint.Win.Spread.ScrollBarTrackPolicy.Horizontal;
fpSpread1.ScrollTipPolicy = FarPoint.Win.Spread.ScrollTipPolicy.Vertical;
VB
Copy Code
Dim fpSpread1 As New FarPoint.Win.Spread.FpSpread()
Dim shv As New FarPoint.Win.Spread.SheetView()
fpSpread1.Location = New Point(10, 10)
fpSpread1.Height = 250
fpSpread1.Width = 400
Controls.Add(fpSpread1)
fpSpread1.Sheets.Add(shv)
fpSpread1.HorizontalScrollBarPolicy = FarPoint.Win.Spread.ScrollBarPolicy.Always
fpSpread1.VerticalScrollBarPolicy = FarPoint.Win.Spread.ScrollBarPolicy.AsNeeded
fpSpread1.HorizontalScrollBarHeight = 30
fpSpread1.VerticalScrollBarWidth = 30
fpSpread1.ScrollBarMaxAlign = True
fpSpread1.ScrollBarShowMax = True
fpSpread1.ScrollBarTrackPolicy = FarPoint.Win.Spread.ScrollBarTrackPolicy.Horizontal
fpSpread1.ScrollTipPolicy = FarPoint.Win.Spread.ScrollTipPolicy.Vertical

Using Code

To display all the scroll bar buttons, set the FpSpread component scroll bar properties.

Example

This example shows all the scroll bar buttons.

C#
Copy Code
fpSpread1.VerticalScrollBar.Buttons = FarPoint.Win.Spread.ScrollBarButtons.HomeEnd | FarPoint.Win.Spread.ScrollBarButtons.PageUpDown | FarPoint.Win.Spread.ScrollBarButtons.LineUpDown | FarPoint.Win.Spread.ScrollBarButtons.Thumb;
fpSpread1.HorizontalScrollBar.Buttons = FarPoint.Win.Spread.ScrollBarButtons.HomeEnd | FarPoint.Win.Spread.ScrollBarButtons.LineUpDown | FarPoint.Win.Spread.ScrollBarButtons.PageUpDown | FarPoint.Win.Spread.ScrollBarButtons.Thumb;
VB
Copy Code
FpSpread1.VerticalScrollBar.Buttons = FarPoint.Win.Spread.ScrollBarButtons.HomeEnd Or FarPoint.Win.Spread.ScrollBarButtons.PageUpDown Or FarPoint.Win.Spread.ScrollBarButtons.LineUpDown Or FarPoint.Win.Spread.ScrollBarButtons.Thumb
FpSpread1.HorizontalScrollBar.Buttons = FarPoint.Win.Spread.ScrollBarButtons.HomeEnd Or FarPoint.Win.Spread.ScrollBarButtons.LineUpDown Or FarPoint.Win.Spread.ScrollBarButtons.PageUpDown Or FarPoint.Win.Spread.ScrollBarButtons.Thumb

Using the Spread Designer

  1. From the Settings menu, select Scrollbars.
  2. In the Scroll Bar tab, set the display and tracking by selecting the options.
  3. Click OK.
  4. From the File menu choose Apply and Exit to apply your changes to the component and exit Spread Designer.

or

  1. Select the Spread component (or select Spread from the pull-down menu).
  2. In the property list for the component (in the Behavior category), select one of the scroll bar properties.
  3. Click the drop-down arrow to display the choices and select a value. Repeat this for each property.
  4. From the File menu choose Apply and Exit to apply your changes to the component and exit Spread Designer.