Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Grid's behaviour similar to Excel list...
Message
De
28/04/2001 07:53:30
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
28/04/2001 06:08:15
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00501202
Message ID:
00501210
Vues:
21
>I want adjust column width in grid by DblClick
>on Header separator (just as in Excel).
>Help me,please.

Alex,
Header has dblclick and each separator belongs to header on left (mean separator dblclick is dblclick on left side header).
Using gridhitest you can check where the dblclick occurred (cell, header, gridline etc).
You could use a formula similar to this to determine width (not complete. ie: doesn't take into account currentcontrol margin):
*grid.init-in your case would be with this.parent and no for each
* unless you want it to apply all columns
For each oColumn in this.Columns
  With oColumn
    lcType = type(.Controlsource)
    lnDotPos = at('.',.Controlsource)
    lcField = substr(.Controlsource,lnDotPos+1)
    lcTable = left(.Controlsource,lnDotPos-1)
    lcSampleText = ''
    lcFont=.FontName
    lnSize=.FontSize
    Do case
      Case lcType = "C"
        Select max(txtwidth(trim(&lcField), lcFont, lnSize)) ;
          from (lcTable) ;
          into array arrTemp
        .Width = .Parent.Gridlinewidth*2 + ;
          arrTemp[1,1] * fontmetric(6, .FontName, .FontSize)
      Case lcType = "M"
        lcSampleText = replicate("HI",20)
      Case lcType $ "DT"
        lcSampleText = transform(eval(.Controlsource))
* case ...
      Otherwise
*...
    Endcase
    If !empty(lcSampleText)
      .Width = .Parent.Gridlinewidth*2 + ;
        txtwidth(lcSampleText, .FontName, .FontSize) * ;
        fontmetric(6, .FontName, .FontSize)
    Endif
  Endwith
Endfor
If you want this to occur in header code than probably you'd want to change header class with a custom one. Or use one of Nick Neklioudov's magic :) Check for that in files section (sorry I'm not a PUTM and not easy for me to get a ref to file).
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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform