Alinhar valor a direita StringGrid
Como posso alinhar os valores de determinada coluna a direita numa StringGrid ?
Obrigado.
Obrigado.
Edurocha
Curtidas 0
Respostas
Lucas Silva
23/08/2004
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;
GOSTEI 0
Edurocha
23/08/2004
Valeu cara, deu certinho.
abraços,
abraços,
GOSTEI 0