Welcome! Log In Create A New Profile

Advanced

Changing color of specific text in a table

Posted by Georgio 
Georgio
Changing color of specific text in a table
April 17, 2009 08:32PM
Hi all,

I'm trying to do something a little different here. I have a routine that
looks at data in a table. If there is a string in a table cell that is upper-case,
then I want to change the text color to red.

Is there a way to do this? This is what I started to do but its returning an
error on:

TABLE_ABSTRACT.Detail[nRowNum][[nStartPos TO nEndPos]]..Color = iDarkRed

Thanks!
Georgio

<< SNIP >>

sTblDetail = TABLE_ABSTRACT.Detail[nRowNum]		// table data to color code		 

WHILE sLineRead <> EOT
	
	n++
	sLineRead = ExtractString(sTblDetail,n,CR)

		// **************************************
		// valid data found, perform color coding
		// **************************************
		IF sLineRead <> EOT THEN
			
			nStartPos = Position(TABLE_ABSTRACT.Detail[nRowNum],sLineRead)
			nEndPos = ((nStartPos + Length(sLineRead)) - 1)
			
			// check if uppercase
			sWorkString = Upper(sLineRead)
			
				
			// *********************************
			// data is uppercase, color code red
			// *********************************
			IF sWorkString = sLineRead THEN
				TABLE_ABSTRACT.Detail[nRowNum][[nStartPos TO nEndPos]]..Color = iDarkRed
			END
			
		END


END
Al
Re: Changing color of specific text in a table
April 18, 2009 10:14AM
Hello Georgio

You don't mention which part of the proc is giving the error - a debug trace will show that.
If it is the colour setting causing the problem then ...
In terms of memory tables (and I assume file tables) I always use the table row display property for colour changes as this fires for each row as it is displayed. So you could test for uppercase in the table row display event rather than a separate procedure

The syntax for a row colour change is:
Tablename[Tablename]..BrushColor = IDarkRed

The syntax for a cell colour change in V12 - I am not sure if earlier versions support cell colours- is :
Tablename[Tablename][ColumnNumber]..BrushColor = IDarkred

Regards
Al



Edited 1 time(s). Last edit at 04/18/2009 10:17AM by Al.
Piet van Zanten
Re: Changing color of specific text in a table
April 18, 2009 01:30PM
Hi Georgio,

Looking at your code I understand that you have a multiline tablecell in which you want to color some parts red. This is not possible on normal text cells. If you change the column type to rtf you can change color using the rtfSelection function. Note that there's mention of a restriction in the Helpfile: rtfSelection can only be used on the table colum currently in edit. So I suppose you have to use returntocapture. Or wait for Windev 14.

Regards,
Piet
Georgio
Re: Changing color of specific text in a table
April 19, 2009 01:06AM
Quote
Piet van Zanten
Hi Georgio,

Looking at your code I understand that you have a multiline tablecell in which you want to color some parts red. This is not possible on normal text cells. If you change the column type to rtf you can change color using the rtfSelection function. Note that there's mention of a restriction in the Helpfile: rtfSelection can only be used on the table colum currently in edit. So I suppose you have to use returntocapture. Or wait for Windev 14.

Regards,
Piet

Thanks Piet! I was trying to color a specific section of a table. I did go the RTF route and found I could only do the color coding in edit mode.

I guess I'll wait until WD14.

Georgio
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: