Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Programmatically Setting Grid Column Dynamic Backcolor
Message
De
02/09/2005 08:57:58
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Titre:
Programmatically Setting Grid Column Dynamic Backcolor
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01046179
Message ID:
01046179
Vues:
94
I have a form class which contains a grid and the grid is populated during runtime. That all works fine. We have decided to set a cell's backcolor depending on the value in the underlying table. I am overlooking something in the process though because I keep receiving the message that the datatype is invalid for this property when I attempt to set the color for the column. My goal is to actually set the backcolor of the cell on the fly to highlight specific values.

Here is an overview of the code in the form class method:
	WITH thisform.currentgrid

		.AddColumn(nColIndex)

		IF !EMPTY(cControl)
			.Columns(nColIndex).AddObject('my'+cControl, cControl)
			.Columns(nColIndex).Sparse = .F.
			IF !EMPTY(cDynamicControl)
				.Columns(nColIndex).DynamicCurrentControl = cDynamicControl
			ELSE
				.Columns(nColIndex).CurrentControl = 'my'+cControl
			ENDIF
		ENDIF

		.Columns(nColIndex).ControlSource = cField
		.Columns(nColIndex).Width = (( FONTMETRIC(6, 'Arial', 9) + 2) * iWidth )

		*---Remove default header and create a custom header so when can get to the header.click event.

		.Columns(nColIndex).RemoveObject('Header1')
		.Columns(nColIndex).NewObject('custHeader1', 'custHeader', 'custHeader.prg')
		.Columns(nColIndex).custHeader1.caption = cHeading
	
		IF !EMPTY(cMask)
			.Columns(nColIndex).Format = cMask
		ENDIF

		.Columns(nColIndex).Visible = .T.
		.Columns(nColIndex).ReadOnly = .F.
		.Columns(nColIndex).Text1.ReadOnly = .F.
		.Columns(nColIndex).Text1.Visible = .T.
		
**---->>>> Below here is the problem code everything else in this method runs fine

		IF PEMSTATUS(thisform,'setpolicygridcolor',5)    && this returns .t.

                    * .recordsource = 'TPOLICY' which is correct
                    * cField = "PO_STATUS" which is also correct and all of the code
                    * above this section has worked for months and is working
                    * In this case nColIndex = 1 (the first column in the grid)
		    
                    colorvalue = thisform.setpolicygridcolor(.recordsource,cField)
                    
                    * Setpolicygridcolor returns the color value
                    * I have tried returning RGB(255,255,255) and 167725 and both return the error
                    * In some cases I want to return something such as:
                    * "thisform.SetStatcolor('policies')"
                    * but I haven't gotten that far in testing yet due to the default return value
                    * of RGB(255,255,255) and 1677725 erroring in my initial tests
		    
                    .Columns(nColIndex).dynamicbackcolor = colorvalue

		ENDIF

**---->>>> Above here is the problem code
			
	ENDWITH
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform