Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Column resize events
Message
De
14/03/2018 13:47:05
 
 
À
14/03/2018 13:12:04
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Divers
Thread ID:
01658748
Message ID:
01658750
Vues:
67
**
*A cursor ys stamps all columns widths in init event (can be also an array).
*Bindevent all grid columns to a custom method yresize that prevent modifying any column width when user try to resize columns.
*you can resize columns proportionally to "preserve grid ratio" by using % column width for each column (this could be another code)

Public oform
oform=Newobject("ygrid_preserveW")
oform.Show
Return

Define Class ygrid_preserveW As Form
  Height = 500
  Width = 700
  AutoCenter = .T.
  Caption = "Grid preserving initial column widths."
  Name = "Form1"

  Add Object grid1 As Grid With ;
    Anchor = 15, ;
    Height = 495, ;
    Left = 1, ;
    Top = 2, ;
    Width = 695, ;
    Name = "Grid1"

  Procedure yresize
    Lparameters nButton, nShift, nXCoord, nYCoord
    *--- aevent create an array laEvents
    Aevents( myArray, 0)
    *--- reference the calling object
    loObject = myArray[1]
    Local N
    N=Int(Val(Substr(loObject.Name,7)    ))
    Sele ys
    Go N
    loObject.Width=xwidth
  Endproc

  Procedure grid1.Init
    Sele * From Home(1)+"samples\data\customer" Into Cursor ycurs
    Create Cursor ys (xwidth  i)
    With This
      .RecordSource="ycurs"
      .RecordSourceType=1
      .DeleteMark=.F.
      .GridLines=0
      .SetAll("fontbold",.T.,"header")
      .SetAll("DynamicBackColor","IIF(MOD(RECNO( ), 2)=0, RGB(212,210,208) , RGB(0,200,0))", "Column")
      For i=1 To .ColumnCount
        Insert Into ys Values ( .Columns(i).Width)  &&gather initial comlumn width to resuse them column  resize event.
        Bindevent(.Columns(i),"resize",Thisform,"yresize")
      Endfor
      Locate
      .Refresh
    Endwith
  Endproc


Enddefine
*
*-- EndDefine: ygrid_preserveW
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform