Fórum alinhamento no stringgrid #222266
25/03/2004
0
galera é possivel centralizar uma palavra em uma celula do stringgrid?
Speedrob
Curtir tópico
+ 0
Responder
Posts
25/03/2004
Spider
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;
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
Gostei + 0
06/08/2004
Lucas Silva
.....
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?
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)