Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Dynamic column colors
Message
De
17/08/2016 09:27:11
 
 
À
17/08/2016 08:08:27
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01639490
Message ID:
01639557
Vues:
93
>It is error 12 - variable not found. It doesn't happen when the form loads, but if you 'call' it from the child grid it pops up.
>
>
This.HighlightForeColor = EVALUATE(This.Columns[1].DynamicForeColor)
>
>I have tried (from grid2)
thisform.grid1.HighlightForeColor = EVALUATE(Thisform.grid1.Columns[1].DynamicForeColor)
, but that gives the same error..

Let's try to isolate the problem. Here it is a small snippet of code that, hopefully, emulates what you're looking for.

People aged 30 and above will be colored in blue, otherwise will be colored in green.

What's in the valid code of the textbox corresponds to the code that process changes in your Grid2: data is changed, and colors in the main grid are refreshed.

If this is really what you're looking for, can you port to your actual code and make it work?
LOCAL TestForm AS FormWithBadlyColoredGrid

m.TestForm = CREATEOBJECT("FormWithBadlyColoredGrid")
m.TestForm.Show(1)
m.TestForm = .NULL.

DEFINE CLASS FormWithBadlyColoredGrid AS Form

	ADD OBJECT Grid1 AS Grid WITH ColumnCount = 2, Top = 10, Left = 10, Height = 120, AllowCellSelection = .F.
	ADD OBJECT Label1 AS Label WITH Top = 160, Left = 10, Caption = "Insert age for the current record", AutoSize = .T.
	ADD OBJECT TextBox1 AS TextBox WITH Top = 180, Left = 10, Value = 0
	ADD OBJECT CheckBox1 AS Checkbox WITH Top = 180, Left = 120, Caption = "Just to receive focus, after Texbox1.valid()", AutoSize = .T.
	
	PROCEDURE Grid1.Init
	
		CREATE CURSOR ACursor (person C(20), age I)

		INSERT INTO ACursor (person, age) VALUES ("John", 27)
		INSERT INTO ACursor (person, age) VALUES ("Carol", 32)
		INSERT INTO ACursor (person, age) VALUES ("Lyn", 24)

		GO TOP

		This.RecordSource = "ACursor"

		This.BackColor = RGB(128,0,64)
		This.ForeColor = RGB(255,0,128)
		This.HighlightBackColor = RGB(255,255,128)
		This.SetAll("DynamicForeColor", "IIF(age>=30,rgb(0,0,255),rgb(0,255,0))")

		This.AfterRowColChange()

	ENDPROC

	PROCEDURE Grid1.AfterRowColChange
	LPARAMETERS ColIndex

		This.HighlightForeColor = EVALUATE(This.Columns[1].DynamicForeColor)
	
	ENDPROC

	PROCEDURE TextBox1.Valid
	
		* replace data
		SELECT ACursor
		REPLACE age WITH This.Value
		
		* refresh grid color in the current row
		Thisform.Grid1.AfterRowColChange()
	
	ENDPROC

ENDDEFINE
----------------------------------
António Tavares Lopes
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform