Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   DrawGrid (https://www.delphipraxis.net/157036-drawgrid.html)

cha0s 26. Dez 2010 00:29

DrawGrid
 
Ich hoffe ich bin hier im richtigen Forum.
Lese die ID und das Verzeichnis eines Bildes aus einer Datenbank aus. Die ID ist auf AutoInc eingestellt. Das heißt der erste Datensatz erhält die ID 1, der zweite 2,....
Nun Folgendes. Ich möchte dieses Bild in eine einzelne Zeile des drawgrids bringen. Nun meine Frage: wie bringe ich Bilder in die zellen des Drawgrids?

lg cha0s

vergessen 26. Dez 2010 03:13

AW: DrawGrid
 
Mit Delphi 2 Desktop ist da wohl kaum was zu machen...

mkinzler 26. Dez 2010 09:45

AW: DrawGrid
 
Was für eine Datenbank?

cha0s 26. Dez 2010 22:01

AW: DrawGrid
 
nene hab Delphi 4 da ist das schon möglich.
Mit Paradox. das mit der db ist aber kein prob...

mschaefer 26. Dez 2010 22:03

AW: DrawGrid
 
Den Datenbankfreaks bringen die lokalen DB´s sicher eher einen mittleidigen Kommentar auf die Lippen, aber D2 konnte schon mit Interbase und hatte sogar schon ein TDBCtrLGrid!

Um mal auf das Problem hinzusteuern erstmal eine Textausgabe im DrawGrid
Delphi-Quellcode:
procedure TForm1.DrawGrid1DrawCell(Sender: TObject; ACol,
  ARow: Integer; Rect: TRect; State: TGridDrawState);
var
  Sx, Sy: string;
begin
  Sx := IntToStr(ARow);
  Sy := IntToStr(ACol);
  with DrawGrid1 do begin
    Canvas.FillRect(Rect);
    Canvas.TextOut(Rect.Left + 2, Rect.Top + 2,
      'Row ' + Sx + ', Column ' + Sy);
    if gdFocused in State then
      Canvas.DrawFocusRect(Rect);
  end;
und nun das mit Bildern

Delphi-Quellcode:
unit Unit1;

interface

uses
procedure TForm1.Button1Click(Sender: TObject);
var jpg : TJPEGImage;
    bmp : TBitmap;
    rect : TRect;
begin
  // load the JPG
  jpg := TJPEGImage.Create;
  jpg.LoadFromFile('D:\Work\grepsearch.JPG');
  // assign in Bitmap
  bmp := TBItmap.Create;
  bmp.Assign(jpg);
  // draw in the DrawGrid;
  rect := DrawGrid1.CellRect(0, 0);
  DrawGrid1.Canvas.StretchDraw(rect, bmp);
end;

procedure TForm1.DrawGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
var jpg : TJPEGImage;
    bmp : TBitmap;
    rectt : TRect;
begin
  // load the JPG
  jpg := TJPEGImage.Create;
  jpg.LoadFromFile('D:\Work\grepsearch.JPG');
  // assign in Bitmap
  bmp := TBItmap.Create;
  bmp.Assign(jpg);
  // draw in the DrawGrid;
  rectt := DrawGrid1.CellRect(0, 0);
  DrawGrid1.Canvas.StretchDraw(rectt, bmp);
end;

procedure TForm1.DrawGrid1SelectCell(Sender: TObject; ACol, ARow: Integer;
  var CanSelect: Boolean);
var
  rect : TRect;
begin
  rect := DrawGrid1.CellRect(ACol, ARow);
  Image1.Canvas.CopyRect(rect, DrawGrid1.Canvas, rect);
end;

end.

Gute Nacht //


Alle Zeitangaben in WEZ +1. Es ist jetzt 19:15 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-2025 by Thomas Breitkreuz