Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Microsoft: FoxPro FAQ


How to freeze the lefmost column in a grid by Mike Gagnon
Posted: 21 Apr 03 (Edited 1 Oct 03)

This example shows how to freeze the first (to freeze more then one column the code complicates itself exponentially) column in a grid. You can see the effect by copying the following in a program and running it and scroll the grid to right, noticing that the first column is always visible. The important code is in the grid's AfterRowColChange.
Public oForm
Define Class grid1 As Grid
    DeleteMark = .F.
    ColumnCount = 5
    PROCEDURE BeforeRowColChange
    Lparameters nColIndex
        thisform.lockscreen = .t.
    Procedure AfterRowColChange
    Lparameters nColIndex
    Local i
    With This
        If .Columns(1).ColumnOrder < .LeftColumn
            For i=.Columns(1).ColumnOrder To .LeftColumn-1
                .Columns(1).ColumnOrder = .Columns(1).ColumnOrder + 1
            For i=.LeftColumn+1 To .Columns(1).ColumnOrder
                .Columns(1).ColumnOrder = .Columns(1).ColumnOrder - 1
    thisform.lockscreen = .f.
    Procedure Init
    With This
        .Columns(1).BackColor = Rgb(255,0,0)
        For i = 1 To .ColumnCount
            .Columns(i).header1.Caption=Justext(.Columns(i).ControlSource) && Line will not work in VFP5.0
Visible = .T.
Define Class form1 As Form
    Procedure Init
    Create Cursor myGridCursor (date1 D,Name c(20),address c(20),phone c(12),zip c(10))
    Insert Into myGridCursor (date1,Name,address,phone,zip) Values (Date(),"Mike","123 nowhere","1-800-555-5555","123432")
    Insert Into myGridCursor (date1,Name,address,phone,zip) Values (Date()+1,"Paul","321 somewhere","1-800-555-6543","0978675")
    Insert Into myGridCursor (date1,Name,address,phone,zip) Values (Date()+3,"John","765 Here","1-800-555-3214","9587464")
    Go Top

Special thanks to SlightHaze for the extra code to prevent the flickering effect.
Mike Gagnon

Back to Microsoft: FoxPro FAQ Index
Back to Microsoft: FoxPro Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close