Fórum StringGrid #175203
15/08/2003
0
Como faço para pintar uma celula, ou uma coluna, ou uma linha, ou a cor da fonte de determinada celula num StringGrid???
Marcela
Curtir tópico
+ 0
Responder
Posts
15/08/2003
Vmotta
coloque essas procedures em seu programa:
no evento OnDrawCell utilize:
espero ter ajudado ... abraço
Vitor <vmotta@eep.br>
procedure DrawCellText;
var
Text: array[0..255] of Char;
begin
StrPCopy( Text, StringGrid1.Cells[ACol, ARow ] );
ExtTextOut( StringGrid1.Canvas.Handle, Rect.Left + 2, Rect.Top + 2,
ETO_CLIPPED or ETO_OPAQUE, @Rect, Text, StrLen( Text ),nil );
end;
{***}
procedure DrawCellColor( CorFundo, CorLetra : TColor );
var
S1, S2 : TColor;
begin
with StringGrid1.Canvas do
begin
S1 := Brush.Color;
S2 := Font.Color;
try
{pinta o fundo com a cor desejada}
Brush.Color := CorFundo;
FillRect( Rect );
{pinta as letras com a cor desejada}
Font.Color := CorLetra;
DrawCellText;
finally
{restaura as cores}
Brush.Color := S1;
Font.Color := S2;
end;
end;
end;
{***}
no evento OnDrawCell utilize:
if ( StringGrid1.Cells[ACol,ARow] = ´X´ ) then DrawCellColor(cor_de_fundo, cor_da_fonte)
espero ter ajudado ... abraço
Vitor <vmotta@eep.br>
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)