alinhamento no stringgrid

Delphi

25/03/2004

galera é possivel centralizar uma palavra em uma celula do stringgrid?


Speedrob

Speedrob

Curtidas 0

Respostas

Spider

Spider

25/03/2004

um pequeno exemplo:

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
Lucas Silva

Lucas Silva

25/03/2004

.....

Esta solução é ótima, mais tem um problema.
Ela escreve outro texto na célula, por cima do texto antigo.

Alguem sabe como resolver isto?


GOSTEI 0
POSTAR