Fastreport DBCross View
I have DBCross Table contain string and integer data
I would like to change the col开发者_JS百科or of the row through specific condition.You can use the PrintCell event of DBCross component, and check the value
procedure DBCross1OnPrintCell(Memo: TfrxMemoView; RowIndex, ColumnIndex, CellIndex: Integer; RowValues, ColumnValues, Value: Variant);
begin
if value < 1000 then
Memo.Color := clRed
end;
as you can see Memo is just TfrxMemoView, so you can change any properties of TfrxMemoView such as font, style and color.
If you only need to change the font appearance and/or background color of a cell based on a specific condition, you have a more simple option of using the highlight function. It is located at the 2nd line of the quick icon with "ab" and a pen with highlight. You can specify a condition and what appearance and background color you want that cell to change into.
But for more complex operation like multiple conditions and the like, the answer by Mohammed will be the most robust way to handle them.
For changing whole row based on 1 value you have 2 options using Mohammed code :
1 . Change the
if value < 1000 then
to
if <DataSet."FieldName"> < 1000 then
and then assigned the event to every cell's BeforePrint for that row.
2 . Change the
Memo.Color := red
to
begin
Cell1Memo.Color := clRed;
Cell2Memo.Color := clRed,
...
end;
精彩评论