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

Color code rows in a grid 1

Status
Not open for further replies.

admdev

Programmer
May 17, 2006
56
US
Hi all,

Hope somebody can help!

I am trying to color code the rows in a grid which contains data from a cursor.

So what I want to do is when the cursor.field='X', I want the row containing the X to be red. When the cursor.field='y', I want the row to be green. In other words, I will have the grid with multiple colors.

Any help would be appreciated.

Thanks.
 
VFP9:
Code:
thisform.Grid1.SetAll([DynamicBackColor],;
                      [ICASE(MyTable.MyField='X', RGB(255,0,0),]+;
                            [MyTable.MyField='Y', RGB(0,255,0),]+;
[RGB(255,255,255))], [Column])

Previuos versions:
Code:
thisform.Grid1.SetAll([DynamicBackColor],;
                      [IIF(MyTable.MyField='X', RGB(255,0,0),]+;
                            [IIF(MyTable.MyField='Y', RGB(0,255,0),]+;
[RGB(255,255,255)))], [Column])

(check for missed brackets :)]

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
 
Thanks both of you for your reply!

bborissov- I tried your suggestion and it's working. One question though. What are the brackets doing here. I am not too clear on that.

Thanks.
 

Admdev,

What are the brackets doing here.

In this context, the brackets are string delimiters, that is, they are an alternative to the single quote or double quote. Borislav used brackets because the string already includes single quotes. He could just as well have used double quotes in place of the brackets.

I'm glad you posted this question. On my VFP beginners' courses, I advise against using brackets in this way .. for a very simple reason: There are many experienced VFP programmers out there who are not familiar with this usage. The very fact that you had to ask for an explanation comfirms that point. For that reason, I think it's best to stick to double or single quotes.

I know some of the folk here are going to disagree with that. I'd just add that there will always be cases where you should use square brackets, such as where the string already contains both single and double quotes. Also, if the string contains just one quote character and nothing else, brackets are more readable (that is, ["] rather than '"').

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
I like using brackets because they have (I'm sure it isn't the right term) auto-matching at least in the more recent versions.

Brian
 

Mike Y,

Besides brackets are used for array elements!

Another good reason to avoid using them for string delimiters.

Brian,

I like using brackets because they have ... auto-matching

Good point. Then again, you can achieve the next best thing with quotes and double-quotes, by setting the syntax highlighting appropriately.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Hi all,

Thanks for replying!

I see now. I have been using double quotes ever since I started developing in Fox Pro. Two very experienced Fox Pro Developers here in our company also use the double quotes.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top