[WD11] Brush color in tables

Startbeitrag von David Egan am 26.08.2009 06:35

Hi
I have a table which has 10 visible rows using different colors for odd & even rows. When this table gets the focus I change the brush color for the whole table. When the table loses the focus I would like to put the display back to the original 2 colors. The following works when there is data on the relevant table row but if there is no data for the row it crashes out with an invalid subscript error eg if there are 2 valid data lines it crashes out on line 3. Any ideas?


FOR i = 1 TO TableCount(Table1,toVisible)
IF modulo(i,2) = 0 THEN
Table1..BrushColor = White
ELSE
Table1..BrushColor = PastelYellow
END
END



Thanks

David

Antworten:

Hello David,

Perhaps this code will do what you need:

FOR EACH ROW OF Table1
____Table1..BrushColor=IsEven(Table1) ? White ELSE PastelYellow
END

HTH.

von Louis Verbraak - am 26.08.2009 06:48
Hi Louis
It didn't crash, but all lines went white. I tried a combination of yours & mine also but still no good.:(

David

von David Egan - am 26.08.2009 07:02
FOR EACH ROW K OF Table1
____Table1[K]..BrushColor=IsEven(Table1) ? White ELSE PastelYellow
END

May be this helps ???

Jan

von Jan de Bruin - am 26.08.2009 07:09
It's even easier:

FOR EACH ROW i OF Table1
____Table1..BrushColor = iDefaultColor
END

Arie


von Arie - am 26.08.2009 07:36
Hello David

The following code works on test in my system in a memory table.
FOR I = 1 TO TableCount(Table1)
IF modulo(I,2) = 0 THEN
Table1..BrushColor = White
ELSE
Table1..BrushColor = PastelYellow
END
END


The ToVisible option only deals with the number of rows "visible" not actual data filled rows, so I assume that's why is doesn't work because it can point to non existant rows, in the sense that they are "visible" but they have no data.

The For Each option won't work because you can only use that syntax when stepping through a file and using the data in the row to trigger something else, you can't change anything in the row or the processing jumps to the last row and stops.

Regards
Al


von Al - am 26.08.2009 07:40
Thanks guys
Still no good, WD11 doesn't support that syntax of FOR EACH ROW. I tried different variations but it either does nothing or stops at my last data line (but without any errors).

Cheers

David

von David Egan - am 26.08.2009 07:51
Hello David

The code example I posted was older style code and does not use the "For Each" syntax
I tested it in V12 and V11.

Is your table a memory table or file browse table ?

Regards
Al

von Al - am 26.08.2009 08:00
Hi Al
My response must have crossed with your first post but I've just tried your solution with the same result (only changes color for data filled rows). I thought the ToVisible option would give me the 10 rows whereas the TableCount option gives me the data filled rows only. The table is a memory table, displaying current invoices for individual customers. In many cases the table only has 2 or 3 data rows. I'm starting to think the only way I'll get this to work is to add some blank lines to give me 10 rows of data, recolor them all and then delete the blank lines again. It seems a lot of stuffing around though for what would appear to be a simple task.

Regards

David

von David Egan - am 26.08.2009 08:53
Hello David,

This should work, when the table is a memorytable or there is no stored item linked to it.

FOR EACH ROW OF Table1
____Table1[Table1]..BrushColor=IsEven(Table1) ? White ELSE PastelYellow
END

HTH.

von Louis Verbraak - am 26.08.2009 08:56
Hi David,

If you can uncheck the option in the table description to display empty lines.

Regards,
Piet.

von Piet van Zanten - am 26.08.2009 09:36
Hello David


It's an interesting puzzle. I think its a bug in V11 because your original code works in V12 !
A variation on your final solution would be to hide a column and then as you fill the table, put something in the hidden column for every row. This gives the correct tablecount

Another thought is to just colour the available lines with your original focus brush colour rather than every line in the table, then when you revert the colours it will all look ok because the blank lines will never change colour in either case

Table FocusGain
i is int = 0
FOR i = 1 TO TableCount(Table1,toVisible)
TableSelectPlus(Table1,i)
Table1[Table1]..BrushColor = iLightCyan
END


TableFocusLoss
i is int = 0
FOR i = 1 TO TableCount(Table1,toVisible)
TableSelectPlus(Table1,i)
IF modulo(i,2) = 0 THEN
Table1[Table1]..BrushColor = White
ELSE
Table1[Table1]..BrushColor = PastelYellow
END
END



Regards
Al

von Al - am 26.08.2009 12:02
Thanks Al
I'd had the same thought and have now done it as per your last suggestion. Not quite what I was hoping to achieve but near enough & I've wasted far too much time to worry about it any more.
Thanks to everyone for all the suggestions.

Regards

David

von David Egan - am 26.08.2009 19:20
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.