Visual Basic: DataGrid Control

Split Object

See Also   Example   Properties   Methods   Events

A Split object represents a split within a DataGrid control.

Remarks

The DataGrid supports Excel-like splits that divide the grid into vertical panes to provide users with different views of a database. Each split is represented by a Split object and contains a group of adjacent columns that scroll as a unit. When a DataGrid object is created, it contains one Split object by default.

You can use splits to present your data in multiple vertical panes. The data panes (or splits) can display data, scroll (vertically) together or independently of each other, and display the same or different columns. You can also use splits to fix one or more columns from scrolling. Unlike other grid products, the fixed columns do not have to be at the left edge of the grid, but can be at the right edge or anywhere in the middle. You can even have multiple groups of fixed columns within a grid.

You cannot stretch a column wider than its split. If you resize a split to be smaller then a column you can still grab the "phantom" splitter bar.

Each Split object maintains its own Columns collection. These independent splits and columns provide you with very powerful and flexible data presentation capabilities.

As mentioned above, a grid (a DataGrid object) initially contains a single split. If additional splits are created, you can determine or set the current split (i.e., the split that has received focus) using the grid's Split property as follows:

' Read the zero-based index of the current split
Variable% = DataGrid1.Split

' Set focus to the split with an index equal to
' Variable%
DataGrid1.Split = Variable%

Each split in a grid is a different view of the same data source, and each split behaves just like an independent grid. If you create additional Split objects without customizing any of the split properties, all splits will be identical and each will behave very much like the original grid with one split.

Some of the properties of the DataGrid control are the same as the properties of a Split object and are considered common. Changes made to a DataGrid control common property also change the same property of the current Split object and vice versa. For example, consider a grid with two splits, and assume that the current split index is 1 (i.e., the grid's Split property is set to 1). If you want to determine the marquee style in use, the following statements are identical:

marquee% = DataGrid1.MarqueeStyle
marquee% = DataGrid1.Splits(1).MarqueeStyle

If the current split index is set to 1, then the following code is equivalent for setting the MarqeeStyle property to dbgSolidCellBorder:

DataGrid1.MarqueeStyle = dbgSolidCellBorder
DataGrid1.Splits(1).MarqueeStyle = dbgSolidCellBorder

Note   Common properties are unique to DataGrid objects and their associated Split objects. No other object pairs possess similar relationships.