ComponentOne True DBGrid for .NET (2.0) Search HelpCentral 

Vertical Scrolling and Split Groups

By default, the grid has only one horizontal split, with split index 0, and its HScrollBar and VScrollBar style property is set to ScrollBarStyleEnum.Automatic. That is, the horizontal or vertical scroll bar will appear as necessary depending upon the column widths and the number of data rows available. The default split's HorizontalScrollGroup and VerticalScrollGroup properties are set to 1. Splits having the same scrollgroup property setting will scroll vertically or horizontally together. When a new split is created, it will inherit both the state of the scroll bars and the Scroll Group properties from the parent split. If all of the splits belonging to the same HorizontalScrollGroup or VerticalScrollGroup have their HScrollBar and VScrollBar style property is set to ScrollBarStyleEnum.Automatic, then True DBGrid will display the vertical scroll bar or horizontal scroll bar only at the rightmost or bottommost split of the scroll group. Manipulating this single scroll bar will cause all splits in the same scroll group to scroll simultaneously.

For example, two additional splits can be created with the following code:

·      Visual Basic

' Create a Split at the left.

Me.C1TrueDBGrid1.InsertHorizontalSplit(0)

 

' Create another.

Me.C1TrueDBGrid1.InsertHorizontalSplit(0)

·      C#

// Create a Split at the left.

this.C1TrueDBGrid1.InsertHorizontalSplit(0);

 

// Create another.

this.C1TrueDBGrid1.InsertHorizontalSplit(0);

·      Delphi

// Create a Split at the left.

Self.C1TrueDBGrid1.InsertHorizontalSplit(0);

 

// Create another.

Self.C1TrueDBGrid1.InsertHorizontalSplit(0); 

The resulting grid display will display as follows:

All three splits will have the same HScrollBar and VScrollBar settings and VerticalScrollGroup setting of 1. However, only one vertical scroll bar will be displayed, within the rightmost split. When the user operates this scroll bar, all three splits will scroll simultaneously.

Vertical splits react in the same manner. After adding two vertical splits to the grid, all of the splits have the same HorizontalScrollGroup value of 1. Thus there is only one horizontal scroll bar at the bottom of the grid, and if this scroll bar is scrolled all three splits will scroll simultaneously.

Change one of the scroll group properties of the splits to create split groups that scroll independently. In the preceding example, setting the HorizontalScrollGroup property of the middle split to 2 creates a new scroll group:

·      Visual Basic

Me.C1TrueDBGrid1.Splits.Item(0,1).HorizontalScrollGroup = 2

·      C#

this.C1TrueDBGrid1.Splits[0,1].HorizontalScrollGroup = 2;

·      Delphi

Self.C1TrueDBGrid1.Splits.Item[0,1].HorizontalScrollGroup := 2;

After this statement executes, scrolling the middle split will not disturb the others, as shown in the following figure.

Note that the middle split now contains a horizontal scroll bar. This scroll bar operates only on the middle split, since it is the only one with its HorizontalScrollGroup property equal to 2. The horizontal scroll bar in the bottommost split now controls the bottom and top splits only. It no longer affects the middle split.

A common application of this feature is to create two independent split groups so that users can compare field values from different records by scrolling each split to view a different set of rows.


Send comments about this topic to ComponentOne.
Copyright © ComponentOne LLC. All rights reserved.