Alinhar valor a direita StringGrid

23/08/2004

0

Como posso alinhar os valores de determinada coluna a direita numa StringGrid ?

Obrigado.


Edurocha

Edurocha

Responder

Posts

23/08/2004

Lucas Silva

Isso é uma complicação pra fazer no StringGrid.
Segue o código:
procedure TForm1.StringGrid1DrawCell(Sender: 
TObject; ACol, 
ARow: Integer; Rect: TRect; State: TGridDrawState); 
var 
strTemp: string; 
Format: integer; 
begin 
strTemp := StringGrid1.Cells[ACol,ARow]; 
StringGrid1.Canvas.FillRect(Rect); 

if (ACol = 0) then // se coluna = 0 alinha ao centro 
Format := DT_CENTER 
else if (ARow = 0) then se linha=0 alinha ao centro 
Format := DT_CENTER 
else // caso contrario a esquerda 
Format := DT_LEFT; //DT_RIGHT alinha a direita 

if (ARow = 0) then 
StringGrid1.Canvas.Font.Style := [fsBold]; 

DrawText(StringGrid1.Canvas.Handle,PChar(strTemp),-1,Rect,Format); 
end;



Responder

23/08/2004

Edurocha

Valeu cara, deu certinho.

abraços,


Responder

Assista grátis a nossa aula inaugural

Assitir aula

Saiba por que programar é uma questão de
sobrevivência e como aprender sem riscos

Assistir agora

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar