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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Highlight Grid Row 2

Status
Not open for further replies.

alisaif

ISP
Apr 6, 2013
418
AE
Hi,

Is is possible to highlight grid row if the pointer move up and down?

Thanks

Saif
 
Hi,

Please have a look at DynamicForeColor and DynamicBackColor

hth

MK
 
Check ALL properties of the Grid which started with "HighLight*"

Borislav Borissov
VFP9 SP2, SQL Server
 
Please have a look at DynamicForeColor and DynamicBackColor

I disagree. It's easier - and more satisfactory - to set AllowCellSelection to .F. and HighlightStyle to 2. You can also use HighlightBackColor and HighlightForeColor to specify the colours of the highlight. (But these only work in VFP 8.0 and above.)

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
In the Grid's Init procedure add:

Code:
PUBLIC grno
grno = RECNO()
THIS.setall("Dynamicbackcolor", ;
  "IIF(RECNO()=grno,RGB(0,0,160),RGB(255,255,255))","Column")
THIS.setall("DynamicForecolor", ;
  "IIF(RECNO()=grno,RGB(255,255,255),RGB(0,0,0))","Column")

In the Grid's AfterRowColChange procedure add:

Code:
LPARAMETERS nColIndex
grno = RECNO()
THISFORM.grid1.REFRESH

This will make each line of the highlighted record in the Grid blue.

This is on the assumption your Grid is called Grid1

Thank you

Steve
 
Steve,

Your code would be better of grno was a property of the grid, or of the form, and not a public variable. I am not one of those people who say you should never use public variables, but I do think that what you are suggesting is an abuse of them.

But, in any case, surely it's easier simply to set the HighlightStyle property, as per my suggestion? After all, that's what that property is for. Or am I missing something?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Steve,

that post you found is from 2004, Highlight properties are rather new. The knowledgebase ages and code becomes obsolete sometimes, if new properties and functionalities are built into VFP. Unfortunately that ended 2007, but End of 2006 was the earliest time you could find VFP9 code. I'm not sure if Highlight-Properties already were introduced in VFP8, but even that would be 2005 perhaps.

It's nothing wrong, you can't know this, and no harm is done, as everyone can pick what works for his VFP version. Just keep in mind, that even good solutions from some time ago may have easier solutions today.

Bye, Olaf.
 
By the way, that's also a reason we seldom just refer to previous threads. I sometimes do, if there are actually very recent similar threads, but otherwise we're not picky about answering things that have been asked earlier, too.

Anyway, you're welcome as answerer, too. It's nice to see you helping anyway, Steve.

Bye, Olaf.
 
Minor correction: VFP 9 shipped in 2004; it was SP2 that shipped in 2007. So code from 2005 or 2006 is probably good for most stuff, though reporting changed.

Tamar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top