Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How many rows are there in grid?
Message
From
11/02/2008 09:09:12
 
 
To
11/02/2008 05:29:02
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01290490
Message ID:
01291375
Views:
8
Cetin --

Very nice solution ... I especially appreciate the concept of the auxiliary cursor (my own attempt at this problem involved using an additional column in the grid's cursor).

A problem of much more interest to me involves being able to set Dynamic* properties that apply ONLY to the first visible row in a grid. I haven't looked at this problem in a long time, having given up on it -- as I recall, there were problems with scrolling and possibly when the grid didn't have focus.

Any ideas on how I might proceed on this one?

Thanks,

Jim




>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
Jim Nelson
Newbury Park, CA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform