PDA

Ver la Versión Completa : mover imagen de celda a celda en un stringgrid


P-programador
31-07-2015, 03:31:57
:rolleyes::rolleyes::rolleyes::rolleyes::rolleyes::rolleyes::rolleyes::rolleyes::rolleyes:

ecfisa
31-07-2015, 05:39:12
Hola P-programador.

En primer término te sugiero que leas como se debe formular una consulta aquí (http://www.clubdelphi.com/foros/guiaestilo.php). Por favor, leelo.

Contesto al título con un ejemplo:

...
implementation

var
ORect: TRect;

procedure TForm1.FormCreate(Sender: TObject);
var
i: Integer;
begin
Image1.Width := 33;
Image1.Height:= 33;
Image1.Visible := False;
for i := StringGrid1.FixedCols to StringGrid1.ColCount-1 do
StringGrid1.ColWidths[i] := 33;
for i := StringGrid1.FixedRows to StringGrid1.RowCount-1 do
StringGrid1.RowHeights[i] := 33;
ORect := StringGrid1.CellRect(StringGrid1.FixedCols, StringGrid1.FixedRows);
end;

procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
sg: TStringGrid;
begin
sg := TStringGrid(Sender);
sg.Canvas.FillRect(Rect);
if (Rect.Left = ORect.Left)and(Rect.Top = ORect.Top) then
sg.Canvas.Draw(ORect.Left, ORect.Top, Image1.Picture.Bitmap);
end;

procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
begin
ORect := StringGrid1.CellRect(ACol, Arow);
end;


Salida:
http://s3.postimg.org/vs1hvz4hv/sgrd_img.gif

Saludos y gracias por tu colaboración :)