?
Solved

Delphi - Load Image , File name stoed in the Database

Posted on 2011-09-23
5
Medium Priority
?
1,533 Views
Last Modified: 2012-05-12
Hi Experts,
I've a Database table (MS SQL) with a field containing Path of a JPeg Image.

How can I show that in my Grid or DBCtrlGrid?

When I Try to use a Calculated field, Error saying Graphic Field can't be Calculated or Lookup field.

Any neat way to handle this?

TIA
0
Comment
Question by:pcssecure
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 19

Accepted Solution

by:
Thommy earned 2000 total points
ID: 36585686
This should help you...

Drawing an image in a cell of a Delphi DBGrid´
http://delphi.about.com/library/weekly/aa032205a.htm

0
 
LVL 19

Expert Comment

by:Thommy
ID: 36585868
This is how your code should look like...
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
  DataCol: Integer; Column: TColumn; State: TGridDrawState);
var
  Image1: TImage;
  ImageWidth: integer;
  fixRect: TRect;
  YourJPEGFileName:string;
begin
  if (Column.Field.FieldName = 'YourFieldName') then begin
    Image1 := TImage.Create(self);

    try

      //add code to get your jpeg filename
      YourJPEGFileName:=...

      Image1.Picture.LoadFromFile(YourJPEGFileName);

      //Adjust the image dimensions
      ImageWidth := (Rect.Bottom - Rect.Top);
      fixRect.Right := Rect.Left + ImageWidth;

      //draw image
      dbgrid1.Canvas.StretchDraw(fixRect,Image1.Picture.Graphic);

    finally
      Image1.Free;
    end;

    //add space for Image
    fixRect.Left := fixRect.Left + ImageWidth;

    //draw default text
    DBGrid1.DefaultDrawColumnCell(fixRect,DataCol,Column,State);
  end;
end;

Open in new window

0
 
LVL 19

Expert Comment

by:Thommy
ID: 36930548
Have you already tried my code????
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 37144316
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question