Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Freezing a pane in a Grid
Message
From
17/10/2001 11:28:05
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00569609
Message ID:
00569638
Views:
30
>Does anyone know of a way to "Freeze panes" in a Visual Fox Pro grid like Microsoft Excel? I would like to enable the user to scroll across the records in the grid but keep the colum of the person's name stationary as they scroll so that they wil l know which records belong to the corresponding name.
>Thanks
>Max

Create a form with custom 'LockCount' property. It holds column count on leftmost to lock. ie: First and last name fields 2.
Add a grid and build as you'd do usually. Add below code to target events.
*Grid.Init
With this
  lnVertScrollWidth = iif(.ScrollBars < 2, 0, sysmetric(5) )
  lnRecAndDelMarkWidth = ( iif(.DeleteMark,0.6,0) + ;
    iif(.RecordMark,0.6,0) ) * lnVertScrollWidth
  lnGridLineWidth = iif(.GridLines < 2, 0, .GridLineWidth )
  lnTotWidth = 0
  For ix = 1 to thisform.lockcount
    lnTotWidth = lnTotWidth + .Columns(ix).Width + lnGridLineWidth
  Endfor
  .Partition = lnTotWidth + lnGridLineWidth + ;
    lnVertScrollWidth + ;
    lnRecAndDelMarkWidth
  .ActivateCell(1,thisform.lockcount+1) && Setfocus to 2nd panel
  .DoScroll(7)    && Scroll page right
Endwith

*Grid.BeforeRowColChange
Lparameters nColIndex
With this
  Do case
  Case inlist(lastkey(),9,4,2)
    If .Panel = 0 and this.Columns(nColIndex).ColumnOrder >= thisform.lockcount
      Nodefault
      .Columns(1).Setfocus()
      .Panel = 1
      .Columns(thisform.lockcount+1).Setfocus()
    Endif

    If .Panel = 1 and  .Columns(nColIndex).Columnorder=.ColumnCount
      .Columns(thisform.lockcount+1).Setfocus()
      .Panel = 0
      .Columns(1).Setfocus()
    Endif
  Case inlist(lastkey(),15,19,26)
    If .Panel = 0 and .Columns(nColIndex).Columnorder=1
      .Columns(1).Setfocus()
      .Panel = 1
      .Columns(.Columncount).Setfocus()
    Endif
    If .Panel = 1 and .Columns(nColIndex).Columnorder=thisform.lockcount+1
      .Columns(thisform.lockcount+1).Setfocus()
      .Panel = 0
      .Columns(thisform.lockcount).Setfocus()
    Endif
  Otherwise
  Endcase
Endwith
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform