Jumat, 25 Maret 2011

memasukan-gambar-ke-dalam-cell-dbgrid-delphi

procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
var
bitmap : TBitmap;
fixRect : TRect;
bmpWidth : integer;
imgIndex : integer;
begin
fixRect := Rect;
if Column.Field = ADOTable1status then
begin
if ADOTable1status.Value = 'Hidup' then
imgIndex := 0
else
imgIndex := 1;
bitmap := TBitmap.Create;
try
ImageList1.GetBitmap(imgIndex,bitmap);
bmpWidth := (Rect.Bottom - Rect.Top);
fixRect.Right := Rect.Left + bmpWidth;
DBGrid1.Canvas.StretchDraw(fixRect,bitmap);
finally
bitmap.Free;
end;
fixRect := Rect;
fixRect.Left := fixRect.Left + bmpWidth;
end;
DBGrid1.DefaultDrawColumnCell(fixRect,DataCol,Column,State);
end;

Tidak ada komentar:

Posting Komentar