Link to home
Start Free TrialLog in
Avatar of KathyBrowning
KathyBrowning

asked on

DBGrid Freeze one column

I need to freeze the first column when scrolling horizontally.  How is this done?
Avatar of stew1
stew1

Kathy,
      Check the property pages for split. Play with this property and it should work.

Stew
here is some info from Microsoft...
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.

Avatar of KathyBrowning

ASKER

Thanks Stew, I have played with this and have been unsuccessful.  The Column that I am trying to freeze is Column 0 (or the first column).  Perhaps you can be a bit more specific.

Thanks,
Kathy
Kathy,
 Here is some code from MSDN. This should help to set up your grid.

Private Sub Form_Load()    ' Before modifying the grid's properties, make sure
    ' the grid is initialized by refreshing the Data    ' control.
    Adodc1.Refresh    ' Create an additional splits:
    DataGrid1.Splits.Add 0 ' Create an additional split
    ' Hide all columns in the leftmost split,
    ' Splits(0), except for columns 0 and 1    Dim Cols As Columns, C As Column
    Set Cols = DataGrid1.Splits(0).Columns    For Each C In Cols
        C.Visible = False    Next C    Cols(0).Visible = True
    Cols(1).Visible = True    ' Configure Splits(0) to display exactly two
    ' columns, and disable resizing    With DataGrid1.Splits(0)        .Size = 2
        .AllowSizing = False    End With
    ' Usually, if you fix columns 0 and 1 from
    ' scrolling in a split, you will want to make them
    ' invisible in other splits:    Set Cols = DataGrid1.Splits(1).Columns
    Cols(0).Visible = False    Cols(1).Visible = False
    ' Turn off the record selectors in Split 1:
    DataGrid1.Splits(1).RecordSelectors = FalseEnd Sub
ASKER CERTIFIED SOLUTION
Avatar of jgv
jgv

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Also, to size the left split so that it is the width of the displayed column:

Right click grid->properties ->splits (tab)

Make sure 'split0' is selected. In the 'SizeMode' dropdown select "2-Number of Columns"
Stew,

I don't want to step on any toes here... And appreaciate your help... but I also have access to the help files.  The comment that jgv sent is more what I was looking for.  

In the future, please post as comments, that way I can decide which 'comment' I decide to use as the appropriate answer.  If two experts have a way of doing something, I accept the comment that I was able to use as the answer.  In this case, it is jgv's.

Sincerely,
Kathy