![]() |
Grafik in DBGrid
Hi Leute,
ich möchte in einem DBGrid in einer Zelle statt des Textes eine Grafik anzeigen. Mit diesem Code von delphi.about.com wird schonmal eine Grafik zusätzlich vor dem Text angezeigt:
Delphi-Quellcode:
Ich probiere nun seit geraumer Zeit den Text zu entfernen, schaffs aber nicht so wirklich.
// dbgridDrawColumnCell
if (Column.Field.FieldName = 'name') then begin bitmap := TBitmap.Create; try //grab the image from the ImageList ImageList1.GetBitmap(0,bitmap); //Fix the bitmap dimensions bmpWidth := (Rect.Bottom - Rect.Top); fixRect.Right := Rect.Left + bmpWidth; //draw the bitmap dbgrid.Canvas.StretchDraw(fixRect,bitmap); finally bitmap.Free; end; // reset the output rectangle, fixRect := Rect; // add space for the graphics fixRect.Left := fixRect.Left + bmpWidth; end; Kann mir da einer auf die Sprünge helfen? Danke euch! |
Re: Grafik in DBGrid
Warum hast du der DBGridspalte überhaupt ein Datenfeld zugewiesen wenn der Inhalt nicht angezeigt werden soll sondern das Bild?
Ohne DB-Feld
Delphi-Quellcode:
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); begin if datacol = 5 then begin ... end; end; |
Re: Grafik in DBGrid
Hi Andreas,
weil ich entsprechend dem Inhalt des Feldes das eine oder das andere Bild anzeigen will. |
Re: Grafik in DBGrid
Den Inhalt des Feldes kannst du doch direkt in der Datenquelle abfragen.
|
Re: Grafik in DBGrid
Womit du auch Recht hast :oops:
Werde es mal Probieren, danke dir. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 11:11 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz