How to Use Splits > Referencing Splits and their Properties |
A TDBGrid object initially contains a single split. If additional splits are created, you can determine or set the current split (that is, the split that has received focus) using the grid's Split property:
Example Title |
Copy Code
|
---|---|
' Read the zero-based index of the current split. Variable% = TDBGrid1.Split ' Set focus to the split with an index equal to Variable%. TDBGrid1.Split = Variable% |
Each split in a grid is a different view of the same data source, and behaves just like an independent grid. If you create additional splits 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.
Note that some properties, such as RecordSelectors and MarqueeStyle, are supported by both the TDBGrid and Split objects. Three rules apply to properties that are common to a grid and its splits:
When you set or get the property of a Split object, you are accessing a specific split, and other splits in the same grid are not affected.
When you get the property of a TDBGrid object, you are accessing the same property within the current split.
When you set the property of a TDBGrid object, you are setting the same property within all splits.
To understand how these rules work in code, consider a grid with two splits, and assume that the current split index is 1 (that is, the grid's Split property returns 1). If you want to determine which marquee style is in use, the following statements are equivalent:
Example Title |
Copy Code
|
---|---|
marquee% = TDBGrid1.MarqueeStyle marquee% = TDBGrid1.Splits(1).MarqueeStyle marquee% = TDBGrid1.Splits(TDBGrid1.Split).MarqueeStyle |
To change the marquee style to a solid cell border for all of the splits in the grid, you would use:
Example Title |
Copy Code
|
---|---|
TDBGrid1.MarqueeStyle = dbgSolidCellBorder |
Note that this statement is equivalent to:
Example Title |
Copy Code
|
---|---|
TDBGrid1.Splits(0).MarqueeStyle = dbgSolidCellBorder TDBGrid1.Splits(1).MarqueeStyle = dbgSolidCellBorder |
Likewise, to set the marquee style of each split to a different value:
Example Title |
Copy Code
|
---|---|
TDBGrid1.Splits(0).MarqueeStyle = dbgNoMarquee TDBGrid1.Splits(1).MarqueeStyle = dbgFloatingEditor |
These rules apply only to a TDBGrid object and its associated Split objects. No other object pairs possess similar relationships.