We are offering our consulting services for all types of projects related to Visual Basic, Outlook, Exchange Server and other Microsoft environments. If you are looking for a high-quality company to provide outstanding consulting services to your organization, email us at firstname.lastname@example.org
This issue shows how to "freeze" columns at the leftmost portion of a grid.
There are two routines in this module. One to freeze columns and one to unfreeze the columns. They are very useful if you have many columns in your grid and need to keep a few important fields visible at all times. A good example of this would be an employee listing where you have columns such as name, address, salary, department, phone number, cell phone number and other fields in a grid. You would probably want to freeze the Name column so when you scroll through the additonal fields you will always know who the data is for based on the "frozen" column at the left.
An interesting enhancement to this routine would be the option to specify the field names to freeze instead of just freezing the leftmost columns.
Public Sub FreezeColumnsOnLeft(grd As TDBGrid, lHowManyColumns As Long)
Performs the work necessary to freeze the number of columns specified in lHowManyColumns on the left side of the grid. You need to pass the grid you want to modify as the first parameter and the number of columns to freeze as the second parameter.
Public Sub UnfreezeColumnsOnLeft(grd As TDBGrid)
This routine performs the opposite function of FreezeColumnsOnLeft. It assumes you have previously called FreezeColumnsOnLeft. If you haven't and you have not defined additional splits nothing will happen. If you have defined additional splits they will be removed since this function just removes the leftmost split.
This source code will freeze the left 2 columns of data in a grid called TDBGrid1. It will then unfreeze the 2 columns and then freeze the three left most columns of data.
FreezeColumnsOnLeft TDBGrid1, 2 UnfreezeColumnsOnLeft TDBGrid1 FreezeColumnsOnLeft TDBGrid1, 3
To see the source code for this issue you must be a subscriber to Code of the Week. If you are a subscriber the source code is available at the following address: http://www.codeoftheweek.com/membersonly/bi/0092.html