Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid Highlight Problem - Can you Duplicate it?
Message
From
16/09/2005 16:04:12
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01049139
Message ID:
01050485
Views:
15
UPDATE: I pulled out the junk I left in there from testing.

Ok, I am now working with my formclass and am running into the same thing. Everything works fine except when I click on a row if a column that typically has a custom dynamicbackcolor (but on the current row it does not) and it is also the currently highlighted (selected) row, then the highlight is displayed as white (the grid default backcolor) instead of the grid highlight color. Any ideas what I am overlooking?

Form.init (This is before the grid is rebuilt)
WITH THIS.pgfprofile.pagpolicy.policygrid
  .ADDPROPERTY('irecno',0)
  THISFORM.gridbackcolor = .backcolor
  THISFORM.gridforecolor = .forecolor
  THISFORM.highlightbackcolor = .highlightbackcolor
  thisform.highlightforecolor = .highlightforecolor
  thisform.highlightstyle = .highlightstyle
ENDWITH
form.setpolicygridcolor() && only run once before form is shown
LOCAL nColumnID
WITH THIS.pgfprofile.pagpolicy.policygrid
  .SETALL('SelectedBackColor', THISFORM.highlightbackcolor)
  .SETALL('SelectedForeColor', THISFORM.highlightforecolor)
  FOR nColumnID = 1 TO .COLUMNCOUNT
    WITH .COLUMNS(nColumnID)
       .DYNAMICBACKCOLOR = "(thisform.GetPolicyGridColor('"+.CONTROLSOURCE+"',"+ALLTRIM(STR(nColumnID))+"))"
      .SPARSE = .F.
    ENDWITH
  ENDFOR
ENDWITH
form.getpolicygridcolor()
PARAMETERS tcControlSource, tcColumn
*--Passed controlsource and column number

PRIVATE defaultcolorvalue, luValue, lnColorRow
defaultcolorvalue = THIS.gridbackcolor
IF TYPE('tcControlSource') <> "C" .OR. EMPTY(tcControlSource)
	RETURN defaultcolorvalue
ENDIF
tcControlSource = IIF(AT('.',tcControlSource) > 0,UPPER(ALLTRIM(SUBSTR(tcControlSource,AT('.',tcControlSource)))),UPPER(ALLTRIM(tcControlSource)))
IF TYPE('tcColumn') <> "N"
  tcColumn = 0
ENDIF

IF TYPE('this.pgfprofile.pagpolicy.policygrid') = "O" .AND. !ISNULL(THIS.pgfprofile.pagpolicy.policygrid)
   WITH THIS.pgfprofile.pagpolicy.policygrid
      IF USED(.RECORDSOURCE)
	SELECT (.RECORDSOURCE)
	defaultcolorvalue = IIF(RECNO(.RECORDSOURCE)<>.irecno,THIS.gridbackcolor,THIS.HIGHLIGHTBACKCOLOR)
	DO CASE
	CASE tcControlSource = "PO_STATUS" 
		lnColorRow = ASCAN(_vstatus, EVALUATE(m.tcControlSource), 1,-1,1,2+4+8)
		IF lnColorRow > 0 .AND. !EMPTY(_vstatus[m.lnColorRow,2])
			defaultcolorvalue =  EVALUATE(_vstatus[m.lnColorRow,2])
			IF tcColumn > 0 .and. TYPE('.columns(tcColumn).text1') = "O"
				IF defaultcolorvalue <> this.gridbackcolor
					.columns(tcColumn).text1.selectedbackcolor = defaultcolorvalue
				ELSE
					.columns(tcColumn).text1.selectedbackcolor = thisform.highlightbackcolor
				ENDIF
			ENDIF
		ENDIF
	CASE tcControlSource = "PO_SUSP" 
		lnColorRow = ASCAN(_vstatus, PO_STATUS, 1,-1,1,2+4+8)
		IF lnColorRow > 0 .AND. !EMPTY(_vstatus[m.lnColorRow,2])
			defaultcolorvalue =  EVALUATE(_vstatus[m.lnColorRow,2])
			IF tcColumn > 0 .and. TYPE('.columns(tcColumn).text1') = "O"
				IF defaultcolorvalue <> this.gridbackcolor
					.columns(tcColumn).text1.selectedbackcolor = defaultcolorvalue
				ELSE
					.columns(tcColumn).text1.selectedbackcolor = thisform.highlightbackcolor
				ENDIF
			ENDIF
		ENDIF
	CASE tcControlSource = "PO_TYPE"
		lnColorRow = ASCAN(_vtype, EVALUATE(m.tcControlSource), 1,-1,1,2+4+8)
		IF lnColorRow > 0 .AND. !EMPTY(_vtype[m.lnColorRow,3])
			defaultcolorvalue = EVALUATE(_vtype[m.lnColorRow,3])
			IF tcColumn > 0 .and. TYPE('.columns(tcColumn).text1') = "O"
				IF defaultcolorvalue <> this.gridbackcolor
					.columns(tcColumn).text1.selectedbackcolor = defaultcolorvalue
				ELSE
					.columns(tcColumn).text1.selectedbackcolor = thisform.highlightbackcolor
				ENDIF
			ENDIF
		ENDIF
	ENDCASE
      ENDIF
   ENDWITH
ENDIF
RETURN m.defaultcolorvalue
Form.pgfprofile.pagpolicy.policygrid.beforerowcolchange()
LPARAMETERS nColIndex
THISFORM.lockscreen = .T.
Form.pgfprofile.pagpolicy.policygrid.afterrowcolchange()
LPARAMETERS nColIndex
this.irecno = RECNO()
THISFORM.lockscreen = .F.
In the calling program, the form is instantiated and then the grid is built:
ofrmProfile = CREATEOBJECT("ProfileForm")
WITH ofrmProfile                  && setup the grid to use the cursor tpolicy
   .setgridsource('TPOLICY')
   .cleargridfields()
   *---Add a (field) Column to the grid
   .addgridfield(1, 'PO_POL', 15, 'Policy Number', '')
   .addgridfield(2, 'PO_STATUS', 6, 'Status', '')
   .addgridfield(3, 'PO_SUSP', 2, '', '', 'CheckBox', 'IIF(PO_SUSP, "myCheckBox", "")')
   .addgridfield(4, 'PO_TYPE', 12, 'Type', '')
   *---Etc
ENDWITH
*--More miscellaneous code and then:
ofrmProfile.SetPolicyGridColor()  && only run once before form is shown
.·*´¨)
.·`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"
Previous
Reply
Map
View

Click here to load this message in the networking platform