Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HIGHLIGHTING A ROW IN A GRID. 1

Status
Not open for further replies.

TrueCode

MIS
Sep 30, 2003
71
LC
I have been dancing with this at little avail. I have a grid based on a table. I want the grid to highlight the current record of the underlying table...

Can someone help...not too good with grids.

------------------------------------->

"I have sought your assistance on this matter because I have exhausted all the help that I can find. You are free to direct me to other source of help"
 
What version of VFP are you using? It's simple in VFP 8.0 (just set some properties of the grid), and not to difficult do code in earlier versions. (I believe there is even a FAQ on this!)

Rick
 
This code is take right from VFP HELP. Just save it into a prg and execute it.


CLOSE ALL && Close tables and databases
OPEN DATABASE (HOME(2) + 'data\testdata')

USE customer IN 0 && Opens Customer table

frmMyForm = CREATEOBJECT('Form') && Create a Form
frmMyForm.Closable = .F. && Disable the window pop-up menu

frmMyForm.AddObject('cmdCommand1','cmdMyCmdBtn') && Add Command button
frmMyForm.AddObject('grdGrid1','Grid') && Add Grid control

frmMyForm.grdGrid1.Left = 25 && Adjust Grid position

frmMyForm.grdGrid1.SetAll("DynamicBackColor", ;
"IIF(MOD(RECNO( ), 2)=0, RGB(255,255,255) ;
, RGB(0,255,0))", "Column") && Alternate white and green records

frmMyForm.grdGrid1.Visible = .T. && Grid control visible
frmMyForm.cmdCommand1.Visible =.T. && "Quit" Command button visible
frmMyForm.grdGrid1.Column1.Header1.Caption = 'Customer ID'

frmMyForm.SHOW && Display the form
READ EVENTS && Start event processing

DEFINE CLASS cmdMyCmdBtn AS CommandButton && Create Command button
Caption = '\<Quit' && Caption on the Command button
Cancel = .T. && Default Cancel Command button (Esc)
Left = 125 && Command button column
Top = 210 && Command button row
Height = 25 && Command button height

PROCEDURE Click
CLEAR EVENTS && Stop event processing, close form
CLOSE ALL && Close table and database
ENDDEFINE

Jim Osieczonek
Delta Business Group, LLC
 
Thanks Guys,

Did not realize this thing was so simple


------------------------------------->

&quot;I have sought your assistance on this matter because I have exhausted all the help that I can find. You are free to direct me to other source of help&quot;
 
Good Day to all,

I'm using VF6. Is there any other way to do it on higher edition of VF?

&quot;IIF(MOD(RECNO( ), 2)=0, RGB(255,255,255) ;
, RGB(0,255,0))&quot;, &quot;Column&quot;)

This will color the grid (white and green) based on the location of the record(odd or even).

How about if I want to display the record in Alphabetical order with alternate color.

Thanks

Victor/Philippines
 
You would have to find something that you would be able to determine alternating records using something besides RECNO(). A query may be the way to go, if it's not too big of a table:

SELECT * FROM MyTable ORDER BY Whatever INTO temptable


-Dave S.-
[cheers]
Even more Fox stuff at:
 
Can you try something like a for, endfor with the &quot;for&quot; counter limit at the grid record count?
Just a thought
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top