Page 1 of 1

Data Grid - set the bg colour of a text chunk

Posted: Tue Jul 17, 2012 9:43 am
by jameshale
I am using a Data Grid to list the results of a user search on text.
The results are returned using the FORM Data Grid with a field for each of the section heading (prefix_head), the line number of the found text (line_num) and the line of found text itself (the_results).

I wanted to enhance this by setting the background colour of the actual found text within the line of text returned.
To test this I simply set the background colour of a specific word and had a look.

The FillInData handler looks like this:

on FillInData pDataArray
set the text of field "prefix_head" of me to pDataArray["prefix_head"]
set the text of field "the_results" of me to pDataArray["the_results"]
set the backgroundcolor of word 5 of field "the_results" to 246,154,62
set the text of field "line_num" of me to pDataArray["line_num"]
end FillInData

This should set the background colour of the fifth word in each "the_results" field to an orange.

Well it does and it doesn't.

It seems to only set the colour on every fifth row.

So it works, but only once in five rows.

What am I missing?

Re: Data Grid - set the bg colour of a text chunk

Posted: Tue Jul 17, 2012 12:15 pm
by Klaus
Hi James,
jameshale wrote:What am I missing?
probably another "of me" :D

Try this:
...
set the backgroundcolor of word 5 of field "the_results" OF ME to 246,154,62
...

Best

Klaus

Re: Data Grid - set the bg colour of a text chunk

Posted: Tue Jul 17, 2012 3:09 pm
by jameshale
yes.
I can see I need to not be so quick to ignore me in my coding :?

Thanks again.

James

Re: Data Grid - set the bg colour of a text chunk

Posted: Tue Jul 17, 2012 3:37 pm
by Klaus
Hi James,

I only knew cause i was hit by this some time ago, too 8)


Best

Klaus