now say the table will look like this:
DATE , Some Text
01.01.2004 , text 1 -> white
01.01.2004 , text 2 -> white
02.01.2004 , text 3 -> gray
02.01.2004 , text 4 -> gray
03.01.2004 , text 5 -> white
04.01.2004 , text 6 -> gray
and so on.
I found out that i can easily get the value of a column of the prior row but
not a background color. i think this is because i can't get a component from
a prior row, but im not sure.
can someone help me with this?
thank you
martin
private Color currentColor = Color.white;
private row currentRow = 0;
public void column_painting(DataSet dataSet, Column column, int row, Variant
value, CustomPaintSite paintSite) {
if (row == 0) {
priorColor = Color.white;
priorRow = 0;
}
else {
DataRow dr = new DataRow(dataSet);
dataSet.getDataRow(row, dr);
Date date = dr.getDate("DATE");
DataRow priorDR = new DataRow(dataSet);
dataSet.getDataRow(row-1, priorDR);
Date priorDate = priorDR.getDate("DATE");
if (date != null && priorDate != null && !date.equals(priorDate) &&
row != priorRow) {
if (priorColor.equals(Color.white)) {
priorColor = new Color(220, 220, 220);
}
else {
priorColor = Color.white;
}
priorRow = row;
}
}
paintSite.setBackground(priorColor);
}
Here are some ideas, none of which have been tested:
1. Add a private static variable to the custom paint site class.
Update it every time the relevant method of the site object
gets called. Since you are essentially toggling between
two colors, use a boolean.
The update will set the current color based on the value
of the static variable and whether the date has changed.
This may not work if painting is not done by iterating rows
from row 0.
2. An alternative might be to use a hidden calculated column,
the values of which are 0/1 or true/false, and are calculated
once, upon loading. The value is toggled based on the same
criterion you stated above. Get the value of that column
for the current row and use that to determine the color.
--
Paul Furbacher (TeamB)
Save time, search the archives:
http://www.borland.com/newsgroups/ngsearch.html
Is it in Joi Ellis's Faq-O-Matic?
http://www.visi.com/~gyles19/fom-serve/cache/1.html
Finally, please send responses to the newsgroup only.
That means, do not send email directly to me.
Thank you.