Solved

Load picture in DrawGrid

Posted on 1998-05-15
1
452 Views
Last Modified: 2011-04-14
HHHHHHEEEEEELLLLLLLPPPPPP

I have got a DrawGrid (size: 10 x 10), and I want to load a picture for example into cell [2,8]. How can I do this? Or do I have to use a StringGrid for this kind of jobs.

DrawGrid1.Image.LoadFromFile('pic.bmp'); DOES NOT WORK !!!

Please help me.

Stefan.
0
Comment
Question by:roosiedb
1 Comment
 
LVL 8

Accepted Solution

by:
ZifNab earned 30 total points
ID: 1345835
Hi roosiedb,

Haven't worked it out totally, but I think you can manage from here....

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

type
  TForm1 = class(TForm)
    DrawGrid1: TDrawGrid;
    procedure DrawGrid1DrawCell(Sender: TObject; Col, Row: Longint;
      Rect: TRect; State: TGridDrawState);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.DrawGrid1DrawCell(Sender: TObject; Col, Row: Longint;
  Rect: TRect; State: TGridDrawState);
var
  bmp : TBitmap;
begin
  with Canvas do
  begin
    FillRect(Rect);
         try
          bmp := TBitmap.Create;
          bmp.Assign('your bitmap');
          Draw(Rect.Left, Rect.Top, bmp);
        finally
          bmp.Free;
        end
  end;
end;
end.

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

867 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now