How to Use Splits > Horizontal Scrolling and Fixed Columns |
Horizontal scrolling is independent for each split. Often, you need to prevent one or more columns from scrolling horizontally so that they will always be in view. True DBGrid provides you with an easy way to keep any number of columns from scrolling at any location within the grid (even in the middle!) by setting a few split properties.
As an example, assume that you have a grid with three splits. The following code will "fix" columns 0 and 1 in the middle split:
Example Title |
Copy Code
|
---|---|
' Hide all columns in Splits(1) except for columns 0 and 1. Dim Cols As TrueDBGrid80.Columns Dim C As TrueDBGrid80.Column Set Cols = TDBGrid1.Splits(1).Columns For Each C In Cols C.Visible = False Next C Cols(0).Visible = True Cols(1).Visible = True ' Configure Splits(1) to display exactly two columns, and disable resizing. With TDBGrid1.Splits(1) .SizeMode = dbgNumberOfColumns .Size = 2 .AllowSizing = False End With |
Usually, if you keep columns 0 and 1 from scrolling in one split, you will want to make them invisible in the other splits:
Example Title |
Copy Code
|
---|---|
' Make columns 0 and 1 invisible in splits 0 and 2.
Dim Cols As Columns
Set Cols = TDBGrid1.Splits(0).Columns
Cols(0).Visible = False
Cols(1).Visible = False
Set Cols = TDBGrid1.Splits(2).Columns
Cols(0).Visible = False
Cols(1).Visible = False
|