Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Jun Tangunan
  Where is Jun Tangunan?
 Cabanatuan
 Philippines
 Jun Tangunan
 To: John Hayna
  Where is John Hayna?
 
 Philippines
 John Hayna
 Tags
Subject: RE: Grid's forecolor
Thread ID: 330955 Message ID: 331221 # Views: 25 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Grids
Date: Tuesday, December 27, 2011 11:44:48 PM         
   


> Hi John,
>
> What do you mean by "don't need to set that DynamicForeColor on every run of your SQL."? Am I doing it? :-U
>
> I didn't know that I'm doing it. So how to approach it to don't set it every run of SQL?
>
> Thanks.
>
> >
> >
> > I am not sure why John because the DynamicForeColor condition is valid. Try this:
> >
> >
Local oForm As Form
> > oForm = Createobject('TestForm')
> > oForm.Show(1)
> > Return
> > 
> > Define Class TestForm As Form
> >     AutoCenter = .T.
> >     Height = 500
> >     Width = 390
> >     Caption = "DynamicForeColor"
> > 
> >     Add Object grid1 As Grid With ;
> >         Left = 10, Top = 45, Width = 370, Height = 420, ColumnCount = 2,;
> >         deletemark = .F., ScrollBars = 2
> > 
> >     Procedure Load
> >         Create Cursor junk ( low1 i, low2 i)
> >         RAND(-1)
> >         FOR lnloop = 1 TO 20
> >            INSERT INTO junk VALUES (50,1 + 100 * RAND( ))
> >         NEXT 
> >         GO TOP 
> >    Endproc
> > 
> >     Procedure Init
> >         With Thisform.grid1 As Grid
> >         .SetAll("dynamicforecolor", "IIF(low2 < low1, RGB(255,0,0), RGB(0,0,0))", "Column")
> >         Endwith
> >     Endproc
> > 
> > Enddefine
> > 
> > 

> >
> >
> > And like I told you, you don't need to set that DynamicForeColor on every run of your SQL. Set it once and it will act properly throughout your usage. To test, when the sample form runs, try manually changing the values and see how the grid will quickly react into that without additional codes.
> >
> >
> > http://sandstorm36.blogspot.com
> > http://weblogs.foxite.com/sandstorm36/default.aspx


See this:


	SELECT t1.lowlvl as low1, t1.itemcode as icode, t2.itemcode as itcode, t2.onhand as low2;
	FROM xLow1 t1;
	LEFT JOIN xLow2 t2 ON t1.itemcode = t2.itemcode;
	WHERE t1.itemcode = t2.itemcode;
	INTO CURSOR crsIfLowThenRed

* you are doing this on every run of SQL SELECT above  	
	thisform.grid1.SetAll("dynamicforecolor", ;
			"IIF(crsIfLowThenRed.low2 < crsIfLowThenRed.low1, RGB(255,0,0), RGB(0,0,0))", "Column")



Just do it once, either in init event of the form or in my example, init event of the grid itself.


http://sandstorm36.blogspot.com
http://weblogs.foxite.com/sandstorm36/default.aspx

ENTIRE THREAD

Grid's forecolor Posted by John Hayna @ 12/24/2011 9:00:42 PM
RE: Grid's forecolor Posted by Mike Gagnon @ 12/25/2011 2:05:43 AM
RE: Grid's forecolor Posted by John Hayna @ 12/26/2011 2:57:17 AM
RE: Grid's forecolor Posted by Jun Tangunan @ 12/26/2011 3:33:04 AM
RE: Grid's forecolor Posted by John Hayna @ 12/26/2011 7:58:35 AM
RE: Grid's forecolor Posted by Jun Tangunan @ 12/27/2011 6:36:38 AM
RE: Grid's forecolor Posted by John Hayna @ 12/27/2011 7:46:20 AM
RE: Grid's forecolor Posted by Jun Tangunan @ 12/27/2011 11:44:48 PM
RE: Grid's forecolor Posted by Mike Gagnon @ 12/25/2011 2:10:47 AM