Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Locking columns in a grid
Message
From
07/11/2001 08:56:55
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
06/11/2001 16:07:21
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00578210
Message ID:
00578451
Views:
17
>Assume a 2 column grid, grid width = 100, column width 1 = 17, column width 2 = 83, scrollbars = 2, gridlines = 0.
>
>Grid is read-only, column 1 being a bitmap representing the file type in column 2.
>
>How can one ensure column 1 does not disappear off left if the user moves around the grid with the keyboard?
>
>TIA
>
>Dennis

Dennis,
Adjust the width till it doesn't need to scroll and disable resizing columns is one way. Another way with resizable columns and multiple (normally wouldn't fit on screen) is to parttion grid :

- Create a form with a custom property named LockCount
- This property would hold number of columns to lock on left
- Add your grid and build as usual
- Copy&paste the code below to their target methods
*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 + iif(.GridLines < 2, 4, .GridLineWidth ) + ;
    lnVertScrollWidth + ;
    max(lnRecAndDelMarkWidth, 1)
  .ActivateCell(1,thisform.lockcount+1) && Setfocus to 2nd panel
  Do while .LeftColumn < thisform.lockcount+1
    .DoScroll(5)    && Scroll right
  Enddo
Endwith

* Grid.BeforeRowColChange
Lparameters nColIndex
With this
  Do case
  Case inlist(lastkey(),9,4,2) && Right
    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
      Nodefault
      .Columns(thisform.lockcount+1).Setfocus()
      .Panel = 0
      .Columns(1).Setfocus()
    Endif
  Case inlist(lastkey(),15,19,26) && Left
    If .Panel = 0
      If .Columns(nColIndex).Columnorder=1
        Nodefault
        .Panel = 1
        .Columns(.Columncount).Setfocus()
      Endif
    Endif
    If .Panel = 1 and .Columns(nColIndex).Columnorder=thisform.lockcount+1
      Nodefault
      .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
Reply
Map
View

Click here to load this message in the networking platform