Cor do texto do grid
06/09/2004
0
Olá turma.. chei um exemplo de como pintrar o fundo do grid pra ele ficar zebrado em uma das revistas do ClubeDelphi, porém estou tentando fazer uma outra coisinha e está dando tilt.. Segue abaixo o script e o q eu estou tentando fazer.
Gostaria q o script fizesse 2 coisas.
1 - Que colocasse o grid zebrado (já está funcionando perfeitamente).
2 - Ele deveria mudar o estilo e a cor da letra em que o registro dt_previsão do banco fosse menor que a data do sistema.
Então coloquei o seguinte cod:
procedure TF_INC_ATA.DG_PRINCIPALDrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
// Pinta célular do grid
if (T_ATA_ASSUNTOSDT_PREVISAO.Value < Date) then
begin
DG_PRINCIPAL.Canvas.Font.color := clRed;
DG_PRINCIPAL.Canvas.Font.Style := [fsBold];
end;
// Pinta Célula
if not odd(DM_DADO.T_ATA_ASSUNTOS.recno) then
if not (gdSelected in State) then
begin
DG_PRINCIPAL.canvas.brush.color := clcian;
DG_PRINCIPAL.canvas.fillRect(Rect);
DG_PRINCIPAL.defaultDrawDataCell(rect,Column.Field,State);
end;
end;
O caso todo é que ele pinta as colunas de cian e coloca as letras em negrito e vermelho.. O q estou fazendo de errado??
Gostaria q o script fizesse 2 coisas.
1 - Que colocasse o grid zebrado (já está funcionando perfeitamente).
2 - Ele deveria mudar o estilo e a cor da letra em que o registro dt_previsão do banco fosse menor que a data do sistema.
Então coloquei o seguinte cod:
procedure TF_INC_ATA.DG_PRINCIPALDrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
// Pinta célular do grid
if (T_ATA_ASSUNTOSDT_PREVISAO.Value < Date) then
begin
DG_PRINCIPAL.Canvas.Font.color := clRed;
DG_PRINCIPAL.Canvas.Font.Style := [fsBold];
end;
// Pinta Célula
if not odd(DM_DADO.T_ATA_ASSUNTOS.recno) then
if not (gdSelected in State) then
begin
DG_PRINCIPAL.canvas.brush.color := clcian;
DG_PRINCIPAL.canvas.fillRect(Rect);
DG_PRINCIPAL.defaultDrawDataCell(rect,Column.Field,State);
end;
end;
O caso todo é que ele pinta as colunas de cian e coloca as letras em negrito e vermelho.. O q estou fazendo de errado??
Zenner
Curtir tópico
+ 0
Responder
Posts
06/09/2004
Motta
teste se a coluna é a que vc quer use o param Column
procedure TF_INC_ATA.DG_PRINCIPALDrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
// Pinta célular do grid
if (T_ATA_ASSUNTOSDT_PREVISAO.Value < Date) then
begin
DG_PRINCIPAL.Canvas.Font.color := clRed;
DG_PRINCIPAL.Canvas.Font.Style := [fsBold];
end;
// Pinta Célula
if Column = ...... // <<== then
begin
if not odd(DM_DADO.T_ATA_ASSUNTOS.recno) then
if not (gdSelected in State) then
begin
DG_PRINCIPAL.canvas.brush.color := clcian;
DG_PRINCIPAL.canvas.fillRect(Rect);
DG_PRINCIPAL.defaultDrawDataCell(rect,Column.Field,State);
end;
end;
end;
procedure TF_INC_ATA.DG_PRINCIPALDrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
// Pinta célular do grid
if (T_ATA_ASSUNTOSDT_PREVISAO.Value < Date) then
begin
DG_PRINCIPAL.Canvas.Font.color := clRed;
DG_PRINCIPAL.Canvas.Font.Style := [fsBold];
end;
// Pinta Célula
if Column = ...... // <<== then
begin
if not odd(DM_DADO.T_ATA_ASSUNTOS.recno) then
if not (gdSelected in State) then
begin
DG_PRINCIPAL.canvas.brush.color := clcian;
DG_PRINCIPAL.canvas.fillRect(Rect);
DG_PRINCIPAL.defaultDrawDataCell(rect,Column.Field,State);
end;
end;
end;
Responder
Clique aqui para fazer login e interagir na Comunidade :)