Atozed Forums

Full Version: Managing text Color in IWDBGrid
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Below is the procedure for processing the onRendercell event of the dgMessage component (TIWDBGrid). 
Problem: 
ACell.BGColor     := clWebLIGHTBLUE - works, 
ACell.Font.Color  := clWebGreen; does not work. 

The background color changes, but the text color does not change.

procedure TfmVmMain.dgMessageRenderCell(ACell: TIWGridCell; const ARow,
  AColumn: Integer);
begin
  with dmVM do
  begin
      case dmVM.mtMessage.FieldByName('TYPE_REC').AsInteger of dmVM.mtMessage.Fieldbyname ('TYPE_REC').AsInteger of
      0 : ACell.Font.Color  := clWebBLACK;
      1 : ACell.Font.Color  := clWebNavy;       // TextFont.Цвет: = clWebNavy; / / текст
      2 : ACell.Font.Color  := clWebGreen;      // Header 1Font.Цвет := clWebGreen; / / Заголовок 1
      3 : ACell.Font.Color  := clWebMaroon;    // Header 2Font.Color := clWebMaroon; / / Заголовок 2
      end;

    if dgMessage.RowIsCurrent then
    begin
      mCurrentMID      := mtMessage.FieldByName('MID').AsString;
      ACell.BGColor    := clWebLIGHTBLUE;//clWebWHITE;
    end else begin
      ACell.BGColor    := clWebGAINSBORO;// clMoneyGreen;// clWebWHITE;
    end;
  end;
end;

Tell me what is wrong?
I will formulate the question more compactly :

procedure TfmVmMain.dgMessageRenderCell(ACell: TIWGridCell; const ARow, AColumn: Integer);
begin
if dgMessage.RowIsCurrent then
begin
ACell.Font.Color := clWebMaroon; // The color is not assigned!
ACell.BGColor := clWebLIGHTBLUE; // The color is assigned, everything works as it should.
end else begin
ACell.Font.Color := clBlack; // The color is not assigned!
ACell.BGColor := clWebGAINSBORO; // The color is assigned, everything works as it should.
end;
end;

If you are using DbGrid a similar approach to the coloring of the lines is working.

Am I doing something wrong or is it not working properly IWDBGrid ?