Hi,
I have a Table Box which contains a large number of rows that group naturally into blocks of three rows each (because rows 1 to 3 relate to one chemical compound, rows 4 to 6 relate to another, rows 7 to 9 relate to a third one, and so on). I'd like to shade the rows to make the blocks of compounds visually easier to distinguish - so I want to shade rows 1 to 3, then leave rows 4 to 6 white, then shade rows 7 to 9, then leave rows 10 to 12 white etc. (The requirement for shading of three rows at a time means I can't just use the "<< shade alternate rows" property.)
I can pre-select every alternate block of three rows with the "<< set selected rows()" property, but that coloring pattern would then be lost if the user were subsequently to click on any of the rows or otherwise select/deselect them. I've therefore applied the same property within the "<< set row change function" property - so if the user clicks anywhere on the table, the shading is immediately reapplied. I end up with something like this:
nameList = repeat({"A"}, 3) || repeat({"B"}, 3) || repeat({"C"}, 3) || repeat({"D"}, 3) || repeat({"E"}, 3) || repeat({"F"}, 3) || repeat({"G"}, 3) || repeat({"H"}, 3);
threeList = {1, 2, 3, 7, 8, 9, 13, 14, 15, 19, 20, 21};
tb = Table Box(
String Col Box("Name", nameList),
Number Col Box("First", index(1, 24)),
Number Col Box("Second", index(25, 48)),
Number Col Box("Third", index(49, 72)),
<< set selected row color("cyan"),
<< set selected rows(threeList),
<< set row change function(tb << set selected rows(threeList)),
<< set scrollable(1),
<< set column borders(1),
<< set underline headings(1)
);
new window("My Window", tb);
This works, but seems a bit convoluted. Can anyone suggest an easier way to do it?
Many thanks.