Solved

Load picture in DrawGrid

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

708 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

15 Experts available now in Live!

Get 1:1 Help Now