Bonjour,
Je souhaite copier une image dans une cellule particulière d'un DrawGrid.
L'image est au format jpg.
Je n'ai pas d'erreur à l'exécution, mais je ne parviens pas à voir mon image.
Voici le code :
Voilà, j'espère que vous pourrez m'aiguiller.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 procedure TForm3.DrawGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); var myRect:TRect; PhotoStation:TImage; begin PhotoStation:=TImage.Create(Self); //PhotoStation.Parent:=Self; PhotoStation.Width:=DrawGrid1.DefaultColWidth; PhotoStation.Height:=DrawGrid1.DefaultRowHeight; PhotoStation.Stretch:=True; //PhotoStation.Top:=100; //PhotoStation.Left:=100; PhotoStation.Picture.LoadFromFile('toto.jpg'); MyRect:=DrawGrid1.CellRect(0,0);// On prends la position de la cellule DrawGrid1.Canvas.CopyRect(MyRect,PhotoStation.Canvas,PhotoStation.Picture.Bitmap.Canvas.ClipRect); // On copie le canevas dans cette cellule PhotoStation.Free; end;
Partager