Registriert seit: 23. Aug 2008
Ort: Keine Ergebnisse gefunden
290 Beiträge
|
AW: DBGrid Icon aus ImageList
3. Feb 2015, 14:36
Hier die Lösung!
Delphi-Quellcode:
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
var
bitmap : TBitmap;
fixRect : TRect;
bmpWidth : integer;
imgIndex : integer;
Wert : String;
begin
fixRect := Rect;
if Column.Field = DBGrid1.DataSource.DataSet.FieldByName('ICON')then
begin
Wert := DBGrid1.DataSource.DataSet.FieldByName('GRID').Value;
if Wert = '1' then begin
ImgIndex := 0;
end else
if Wert = '0' then begin
ImgIndex := 1
end;
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;
|
|
Zitat
|