I have a five column stringgrid which I want to use a different font colour (for the entire row) based on the value of column 2 (Col 1 in code). So far it works, but only changes the font colour for column 2. I have tried numerous things, but the best I can do is change the colour for columns 1 (Col 0) 0and 2 (Col 1).
Any ideas?
Here is my code:
------------------------------------
There's no place like 127.0.0.1
------------------------------------
Any ideas?
Here is my code:
Code:
procedure TfrmMain.sgInvoiceDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
S,strItemType: String;
drawrect :trect;
begin
//paint column backcolour
Case ACol of
1:
begin
//check whether item has been configured to a service/music/hardware item
//and paint font colour to that of the colours used in item configuration
//listboxes
if sgInvoice.Cells[ACol,ARow] = '' then exit;
strItemType := RetrieveTYPE(sgInvoice.Cells[ACol,ARow]);
if strItemType = 's' then
begin
sgInvoice.Canvas.Font.Color := clMaroon;
sgInvoice.Canvas.TextOut(Rect.Left + 2, Rect.Top + 2, sgInvoice.Cells[ACol, ARow]);
end
else if strItemType = 'm' then
begin
sgInvoice.Canvas.Font.Color := clTeal;
sgInvoice.Canvas.TextOut(Rect.Left + 2 , Rect.Top + 2, sgInvoice.Cells[ACol, ARow]);
end
else if strItemType = 'h' then
begin
sgInvoice.Canvas.Font.Color := clOlive;
sgInvoice.Canvas.TextOut(Rect.Left + 2 , Rect.Top + 2, sgInvoice.Cells[ACol, ARow]);
end;
end;
3:
begin
sgInvoice.Canvas.Brush.Color := clCream; //clBtnFace;
sgInvoice.Canvas.FillRect(Rect);
sginvoice.Canvas.Font.Color := clBlack;
sgInvoice.Canvas.TextOut(Rect.Left + 2 , Rect.Top + 2, sgInvoice.Cells[ACol, ARow]);
end;
else
begin
sgInvoice.Canvas.Brush.Color := clWindow;
sgInvoice.Canvas.FillRect(Rect);
sgInvoice.Canvas.Pen.Color := clBlack;
sgInvoice.Canvas.TextOut(Rect.Left + 2, Rect.Top + 2, sgInvoice.Cells[ACol, ARow]);
end;
end; {case}
......
......
end;
------------------------------------
There's no place like 127.0.0.1
------------------------------------