Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid Highlight Problem - Can you Duplicate it?
Message
From
16/09/2005 04:10:03
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
15/09/2005 22:40:09
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:
01050163
Views:
24
This message has been marked as a message which has helped to the initial question of the thread.
Tracy,
Few days yes but being a long thread I thought it was already solved from the start with the previous sample I sent:( Other forum caught my notice. Was this what you're looking for?
Close Databases All
Create Table tpolicy (po_number c(25), po_name c(20), po_status c(3))
Insert Into tpolicy Values ("John T. Smith","123456","CXP")
Insert Into tpolicy Values ("Sally A. Taylor","789012","NB")
Insert Into tpolicy Values ("Craig Abernathy","AAB123","REN")
Insert Into tpolicy Values ("Chris Johnson","890123","AP")

Create Table vstatus (st_status c(3), st_attrib i)
Insert Into vstatus Values ("CXP",Rgb(255,128,192))
Insert Into vstatus Values ("NB",Rgb(255,255,0))
Insert Into vstatus Values ("AP",Rgb(128,255,255))
Close Databases All

Public oForm
oForm = Createobj('testform')
oForm.Show()

Define Class testform As Form
	DataSession = 2
	Height = 227
	Width = 461
	DoCreate = .T.
	Caption = "Test Highlight Change "
	gridbackcolor = Rgb(0,128,192)
	gridforecolor = Rgb(0,0,0)

	Add Object grid1 As Grid With ;
		ColumnCount = 3, Height = 200, Left = 24, ;
		RecordSource = "tpolicy", Top = 12, Width = 410

	Procedure Load
		Use tpolicy In 0
	Endproc

	Procedure Init
		DoDefault()
		This.AddProperty('_vStatus[1]')
		This.AddProperty('_vType[1]','')
		Select st_status, st_attrib ;
			FROM vstatus ;
			WHERE !(st_status == '') ;
			into Array This._vstatus
		Use In 'vstatus'
		With This.grid1
			.SetAll('SelectedBackColor', This.gridbackcolor)
			.SetAll('SelectedForeColor', This.gridforecolor)
			.Column1.ControlSource = "tpolicy.po_number"
			.Column2.ControlSource = "tpolicy.po_status"
			.Column3.ControlSource = "tpolicy.po_name"
			.Column1.Header1.Caption = "po_number"
			.Column2.Header1.Caption = "po_status"
			.Column3.Header1.Caption = "po_name"
		Endwith
		This.SetPolicyGridColor()
	Endproc

	Procedure SetPolicyGridColor
		Local nColumnID
		With This.grid1
			For nColumnID = 1 To .ColumnCount
				With .Columns(nColumnID)
					.DynamicBackColor = "(thisform.GetPolicyGridColor('"+.ControlSource+"'))"
				Endwith
			Endfor
		Endwith
	Endproc

	Procedure getpolicygridcolor
		Lparameters tcControlSource
		Local defaultcolorvalue,lcColorField, luValue, lnColorRow
		With Thisform.grid1
			defaultcolorvalue = Iif(Recno(.RecordSource) = .nCurrec,This.gridbackcolor,0xFFFFFF)
		Endwith
		tcolorfield = Upper(Justext(m.tcControlSource))

		If Type(m.tcControlSource) = 'G'
			Return m.defaultcolorvalue
		Endif
		luValue = Evaluate(m.tcControlSource)

		Do Case
			Case tcolorfield == "PO_SUSP" Or tcolorfield == "PO_STATUS"
				lnColorRow = Ascan(This._vstatus, m.luValue, 1,-1,1,2+4+8)
				Return Iif(m.lnColorRow > 0, This._vstatus[m.lnColorRow,2], m.defaultcolorvalue )
			Case tcolorfield = "PO_TYPE"
				lnColorRow = Ascan(This._vtype, m.luValue, 1,-1,1,2+4+8)
				Return Iif(m.lnColorRow > 0, This._vtype[m.lnColorRow,2], m.defaultcolorvalue )
		Endcase
		Return m.defaultcolorvalue
	Endproc

	Procedure grid1.Init
		This.AddProperty('nCurrec',0)
	Endproc

	Procedure grid1.BeforeRowColChange
		Lparameters nColIndex
		Thisform.LockScreen = .T.
	Endproc

	Procedure grid1.AfterRowColChange
		Lparameters nColIndex
		This.nCurrec = Recno()
		Thisform.LockScreen = .F.
	Endproc
Enddefine
Cetin


>WOW. I can't thank you enough. As you know, this has stumped me and drove me crazy for a few days now. I was actually furiously working on it at home and didn't catch your UT message and posts or emails until a couple of hours later. Needless to say, I really appreciate your contribution Nick and I think many can benefit from your efforts on this. It's a great class you created!!!! I hope everyone takes a look at it.
>
>Tracy
>
>
>>Hi Tracy,
>>
>>I solved your task with the customized version of Grid Highlighter. Catch e-mail.
>>
>>>I would appreciate if anyone willing to test this would. Watch the 3rd column highlighting in the code below. On my system, in both VFP8 and VFP9, on Windows XP when there is a special color in the background (as in row 1, column2) the 3rd column is not highlighted. Yet it should be. On the row where there is no special background color, the 3rd column highlights correctly. For example, in the test code below, run it and then use the down arrow to move through rows. The 3rd column only highlights correctly when the cursor is in the 3rd row where there is no special background color in the 2nd column. When there is a special background color, the background color should show, not the highlight and that part is working correctly in all rows. Are you seeing the same thing?
Ç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
Next
Reply
Map
View

Click here to load this message in the networking platform