Solved

Load picture in DrawGrid

Posted on 1998-05-15
1
459 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

809 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