Mega Code Archive

 
Categories / Delphi / VCL
 

Dbgrid içine resim eklemek

'Kaç zamandır nunu arıyordum buldum walla hemen paylaşma istedim...' {You can use the OnDrawColumnCell event to to place icons in DBGrid instead of the values of field. Here's the easy way to do it:} procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); var Icon: TBitmap; begin Icon:=TBitmap.Create; if (Column.FieldName='SHARES' ) then begin with DBGrid1.Canvas do begin Brush.Color:=clWhite; FillRect(Rect); if (Table1.FieldByName('SHARES').Value>4500) then ImageList1.GetBitmap(1,Icon) else ImageList1.GetBitmap(0,Icon); Draw(round((Rect.Left+Rect.Right-Icon.Width)/2),Rect.Top,Icon); end; end;