Specifies the number of columns to lock in the right panel of a grid, beginning at the left edge. Read/write at design time and run time.
After LockColumns is set, the ability to move columns is disabled. Locked columns remain in the grid or Browse window when tabbing to the right.
Grid.LockColumns [ = nValue ]
- Numeric data type. Specifies a number of columns to lock in the right panel of a grid. The default value is 0. If nValue is greater than 0, setting nValue to 0 removes the current number of columns locked.
A grid always contains two panels; however, only the right panel is visible when in default mode. You can activate the left panel by setting the SplitBar property to True (.T.) and dragging the split bar in the user interface to expose the left panel, or by setting a value for the Partition property.
A column separator line, which appears 1 pixel wider than the line separating the other columns, indicates the area where the locked columns end and the normal columns begin.
LockColumns applies only to the right grid panel, which is displayed by default. To lock columns in the left grid panel, when exposed via the Partition or SplitBar properties, use the LockColumnsLeft property.
The Column SetFocus method does not work if a column is locked and not visible in the grid window, for example, scrolled off to the left side.
When any of the locked columns scroll out of the Grid window to the left, they remain out of view and do not become visible again until locking is removed. For example, suppose a grid contains five columns, and the data source has ten columns. When you scroll two columns to the right, the first and second columns scroll out of the grid to the left.
Suppose you set LockColumns with the following code:
Grid.LockColumns = 3
The first, second, and third columns are now locked. The third column appears as the first visible column in the locked grid, even though the first and second columns still exist and remain out of view. You cannot scroll to the left to view all of the locked columns. This functionality is useful if you want to lock the columns in the middle of the grid and do not want to display the preceding or following columns.
The following example demonstrates how to use LockColumns with BROWSEВ ...В NAME:
CLOSE DATABASES OPEN DATABASE testdata && Open testdata database in \Samples\Data. USE Customer BROWSE NAME Customer Customer.LockColumns = 2 && Locks first two columns in right pane.