AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Grafik in DBGrid

Ein Thema von bwolf · begonnen am 20. Mai 2009 · letzter Beitrag vom 20. Mai 2009
Antwort Antwort
bwolf

Registriert seit: 17. Jan 2006
368 Beiträge
 
Delphi 2009 Professional
 
#1

Grafik in DBGrid

  Alt 20. Mai 2009, 10:14
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:
  // 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;
Ich probiere nun seit geraumer Zeit den Text zu entfernen, schaffs aber nicht so wirklich.
Kann mir da einer auf die Sprünge helfen?

Danke euch!
  Mit Zitat antworten Zitat
Andreas Schilling

Registriert seit: 6. Sep 2006
106 Beiträge
 
Delphi 10.3 Rio
 
#2

Re: Grafik in DBGrid

  Alt 20. Mai 2009, 10:52
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;
  Mit Zitat antworten Zitat
bwolf

Registriert seit: 17. Jan 2006
368 Beiträge
 
Delphi 2009 Professional
 
#3

Re: Grafik in DBGrid

  Alt 20. Mai 2009, 11:17
Hi Andreas,

weil ich entsprechend dem Inhalt des Feldes das eine oder das andere Bild anzeigen will.
  Mit Zitat antworten Zitat
Andreas Schilling

Registriert seit: 6. Sep 2006
106 Beiträge
 
Delphi 10.3 Rio
 
#4

Re: Grafik in DBGrid

  Alt 20. Mai 2009, 11:33
Den Inhalt des Feldes kannst du doch direkt in der Datenquelle abfragen.
  Mit Zitat antworten Zitat
bwolf

Registriert seit: 17. Jan 2006
368 Beiträge
 
Delphi 2009 Professional
 
#5

Re: Grafik in DBGrid

  Alt 20. Mai 2009, 11:45
Womit du auch Recht hast
Werde es mal Probieren, danke dir.
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 00:00 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz