Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   OOP (https://www.clubdelphi.com/foros/forumdisplay.php?f=5)
-   -   mover imagen de celda a celda en un stringgrid (https://www.clubdelphi.com/foros/showthread.php?t=88790)

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

mover imagen de celda a celda en un stringgrid
 
: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í. Por favor, leelo.

Contesto al título con un ejemplo:
Código Delphi [-]
...
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:


Saludos y gracias por tu colaboración :)


La franja horaria es GMT +2. Ahora son las 11:56:53.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi