Colocar a imagem. Adapte as suas necessidades.
private
{ Private declarations }
Bitmap: TBitmap;
procedure TForm1.FormCreate(Sender: TObject);
var
x , y : Integer;
begin
for x := 0 to sg.ColCount do
for y := 0 to sg.RowCount do
sg.Cells[x,y] := IntToStr(x) + IntToStr(y);
Bitmap := TBitmap.Create;
Bitmap.LoadFromFile('c:\ImagensBotao\proximo.bmp');
end;
procedure TForm1.sgDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
y , x , AlinharA : integer;
begin
// AlinharA := 0; // Esquerda
// AlinharA := 1; // Centro
// AlinharA := 2; // Direita
if ACol in [ 0 , 1 ] then
AlinharA := 1
else if ACol = 2 then
AlinharA := 2
else
AlinharA := 0;
if gdFixed in State then
begin
sg.Canvas.Brush.Color := clBtnFace;
AlinharA := 1;
sg.Canvas.Font.Style := sg.Canvas.Font.Style + [fsBold];
end
else
begin
sg.Canvas.Brush.Color := clWhite;
sg.Canvas.Font.Style := sg.Canvas.Font.Style - [fsBold];
end;
y := Rect.Top + (Rect.Bottom - Rect.Top -
sg.Canvas.TextHeight(sg.Cells[ACol, ARow]) ) div 2;
case AlinharA of
1: x := Rect.Left +
(Rect.Right - Rect.Left - sg.Canvas.TextWidth(sg.Cells[ACol, ARow])
) div 2 -
1; // Centro
2: x := Rect.Right - sg.Canvas.TextWidth(sg.Cells[ACol, ARow]) - 2; //
Direita
else
x := Rect.Left + 2; // Esquerda
end;
sg.Canvas.TextRect(Rect, x , y, sg.Cells[ACol, ARow]);
sg.Canvas.Draw(Rect.Left+2,Rect.Top+5,Bitmap);
{desenha o retângulo de foco}
if gdSelected in State then
sg.Canvas.DrawFocusRect(Rect);
if gdFocused in State then
sg.Canvas.DrawFocusRect(Rect);
end;
Espero ter ajudado.
BandaLemuel <[EMAIL PROTECTED]> escreveu:
Alguem sabe como colocar imagem no StringGrid...??
Preciso que em tempo de execução... alterar esta imagem tbm.... alguem tem
ideia de como fazer ???
Wesley
[As partes desta mensagem que não continham texto foram removidas]
Flickr agora em português. Você cria, todo mundo vê. Saiba mais.
[As partes desta mensagem que não continham texto foram removidas]