Bonjour à tous,

je voudrais savoir si il était possible d'insérer une image PNG dans un TStringGrid ?

Actuellement je peux le faire avec des images BMP. dans le OnDrawCell :

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
19
20
21
22
23
 
  TImage *Checked = new TImage (NULL);
  TRect R;
  if(ACol == 8 && StringGrid->Cells[0][0] != "vide" && StringGrid->Cells[0][0] != "")
  {
	StringGrid->Canvas->Brush->Color = clWhite;
	StringGrid->Canvas->Font->Color = clWhite;
	StringGrid->Canvas->FillRect(Rect);
 
	R.Left = -2;
	R.Right = Rect.Right - Rect.Left - 2;
	R.Top = -2;
	R.Bottom = Rect.Bottom - Rect.Top - 2;
 
	if(StringGrid->Cells[ACol][ARow] == 1)
	  Checked->Picture->Bitmap= pImageOK;
	else if(StringGrid->Cells[ACol][ARow] == 0)
	  Checked->Picture->Bitmap = pImageNO;
 
	StringGrid->Canvas->CopyRect(Rect, Checked->Picture->Bitmap->Canvas, R);
  }
 
pImageOK et pImageNO sont actuellement des TBitmapImage chargés depuis une DLL
J'aimerais en faire autant avec des TPngImage.

J'ai modifié le code pour charger les PNG dans le TImage :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
 
	if(StringGrid->Cells[ACol][ARow] == 1)
	  Checked->Picture->Assign(pImageOK);
	else if(StringGrid->Cells[ACol][ARow] == 0)
	  Checked->Picture->Assign(pImageNO);
Malheureusement cela ne fonctionne pas.

Merci à tous