Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How many rows are there in grid?
Message
De
11/02/2008 05:29:02
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
09/02/2008 13:11:51
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Divers
Thread ID:
01290490
Message ID:
01291342
Vues:
8
Recno() and relativerow are still easy answers really when the grid has filtered or sorted data.

However for your intent, it's another story and doing alternating rows is best done with an auxillary cursor (IMHO). ie:
Public oform

oform=Newobject("myform")
oform.Show

Define Class myform As Form
  DataSession = 2
  Top = 0
  Left = 0
  Height = 325
  Width = 564
  DoCreate = .T.
  Caption = "Form1"
  Name = "Form1"

  Add Object grdcustomer As Grid With ;
    ColumnCount = 12, ;
    Height = 273, ;
    Left = 11, ;
    RecordSource = "customer", ;
    RecordSourceType = 1, ;
    Top = 5, ;
    Width = 541, ;
    Name = "grdCustomer"

  Add Object combo1 As ComboBox With ;
    Height = 24, ;
    Left = 108, ;
    Top = 288, ;
    Width = 132, ;
    Name = "Combo1"


  Add Object label1 As Label With ;
    Caption = "Change tag to", ;
    Height = 17, ;
    Left = 12, ;
    Top = 292, ;
    Width = 84, ;
    Name = "Label1"


  Procedure Init
    With This.grdcustomer
      .AddProperty('CurrentOrder',0)
      Select Recno() As RcNo, 1 As OrderCol ;
        from (.RecordSource) ;
        order By OrderCol  ;
        into Cursor crsOrdering ;
        readwrite
      Select crsOrdering
      Index On RcNo Tag RcNo

      Select (.RecordSource)
      Local lcAlternatingExpression
      lcAlternatingExpression = "Recno('crsOrdering')%2=0"
      *!*	Borrowed expression from Fabio Lunardon - alternate in 2 rows groups
      *!*   lcAlternatingExpression = "BitTest((Recno('crsOrdering')-1)/2,0)"

      .SetAll("DynamicBackColor", ;
        "IIF(Seek(Recno(this.recordsource),'crsOrdering','rcno') and "+;
        m.lcAlternatingExpression+",0xC0C0C0,0xFFFFFF)", "Column")
    Endwith
  Endproc

  Procedure grdcustomer.Refresh
    Local lcOrder, lnOrder
    With This
      Select (.RecordSource)
      lnOrder = Val(Sys(21))
      If .CurrentOrder # m.lnOrder
        lcOrder = Iif(m.lnOrder = 0,'1',Key(m.lnOrder))
        Select Recno() As RcNo, &lcOrder As OrderCol ;
          from (.RecordSource) ;
          order By OrderCol  ;
          into Cursor crsOrdering ;
          readwrite
        Select crsOrdering
        Index On RcNo Tag RcNo
        Select (.RecordSource)
        .CurrentOrder = m.lnOrder
      Endif
    Endwith
  Endproc


  Procedure combo1.InteractiveChange
    Select customer
    If ( This.Value == "None" )
      Set Order To 0
    Else
      Set Order To Tag (This.Value)
    Endif
    Thisform.grdcustomer.Refresh()
  Endproc


  Procedure combo1.Init
    Select customer
    This.AddItem( "None" )
    For ix=1 To Tagcount()
      This.AddItem( Tag(ix) )
    Endfor
  Endproc

  Procedure Load
    Use (_samples+'data\customer')
  ENDPROC

Enddefine
Dynamic* would work even scrolled provided you set it for columns that are visible.
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform