Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Alternate color columns in a Grid?
Message
From
08/11/2004 08:37:00
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
05/11/2004 16:19:05
Calvin Smith
Wayne Reaves Computer Systems
Macon, Georgia, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00958685
Message ID:
00959112
Views:
39
>I am using these commands to color the current row and alternate the color in 1 column of a data grid:
>
>with thisform.grid1
>.nRecNo=recno('pdfs') .setall('dynamicbackcolor','iif(recno(this.recordsource)=this.nRecNO,rgb(192,192,192),rgb(255,255,255))','column')
>.column4.dynamicbackcolor='iif(mod(thisform.grid1.activerow,2)=1,rgb(255,255,0),rgb(255,128,192))'
>.SetFocus()
>endwith
>
>The reason I am using Thisform.grid1.activerow to set the dynamicbackcolor rather than the .nRecNo property is that this data is not in recno order and cannot easily be made to be in recno order.
>
>All works well until the user clicks to do a page down on the scroll bar. Column4 then becomes 1 color and stays so until the user either clicks on the grid or does a key event to move the record pointer in the grid.
>
>I have put the .column4.dynamicbackcolor line of code in the grids scrolled event, but no joy.
>
>Any suggestions?

Never use ActiveRow for such things.
*Form.init
With this.myGrid
    .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)

	.SetAll("DynamicBackColor", ;
	"IIF(Seek(Recno(this.recordsource),'crsOrdering','rcno')"+;
        " and Recno('crsOrdering')%2=0,0xC0C0C0,0xFFFFFF)", "Column")
endwith

*MyGrid.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

*Sample button click
Select myTable
Set Order To Tag 'SomeTag'
thisform.myGrid.Refresh()
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