Alinhar valor a direita StringGrid
23/08/2004
0
Como posso alinhar os valores de determinada coluna a direita numa StringGrid ?
Obrigado.
Obrigado.
Edurocha
Curtir tópico
+ 0
Responder
Posts
23/08/2004
Lucas Silva
Isso é uma complicação pra fazer no StringGrid.
Segue o código:
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
Clique aqui para fazer login e interagir na Comunidade :)