Board index » delphi » using a dbedit field to load a picture in an image field

using a dbedit field to load a picture in an image field

Hi, I know that this question is probably VERY basic, but I can't
figure it out... I have a DBEdit field in my form .. the datafield is
named FILENAME and it contains a filename in it.

I have an image field (called IMAGE1) that I'd like to load the file
into (and display).

I have the following:

image1.stretch:=true;
image1.Picture.LoadFromFile(dbedit1.datafield);

I tried a whole lot of things and got different error messages... if
the dbedit field contains TEST.BMP, I'd like for it to be loaded into
image1...

Can someone help me out?

Thanks... Kevin

 

Re:using a dbedit field to load a picture in an image field


Quote
Kevin Coleman wrote:

> Hi, I know that this question is probably VERY basic, but I can't
> figure it out... I have a DBEdit field in my form .. the datafield is
> named FILENAME and it contains a filename in it.

> I have an image field (called IMAGE1) that I'd like to load the file
> into (and display).

> I have the following:

> image1.stretch:=true;
> image1.Picture.LoadFromFile(dbedit1.datafield);

> I tried a whole lot of things and got different error messages... if
> the dbedit field contains TEST.BMP, I'd like for it to be loaded into
> image1...

> Can someone help me out?

> Thanks... Kevin

Perhaps you did not give the path.
This works:
Image1.Picture.LoadFromFile('c:\usr\scanned\Rp11l_06.bmp');

Re:using a dbedit field to load a picture in an image field


If it's your code then you know which field in the underlying table the
DBEdit is pointing to so why not access the field:
Image1.Picture.LoadFromFile(Table1FILENAME.AsString);

If the filename is not fully qualified and you know the directory the BMPs
are in then use:
Image1.Picture.LoadFromFile(YourDir+Table1FILENAME.AsString);

The above presumes you don't want the end user to be able to edit the
filename. If you do, then you could put the following in the DBEdit's
ONEXIT event handler:
Image1.Picture.LoadFromFile(YourDir+DBEdit1.text);

--
Paul Motyer
pa...@linuxserver.pccity.com.au
SoftStuff, Croydon, Vic,  Australia, 3136.

Kevin Coleman <kcole...@pipeline.com> wrote in article
<56njmv$...@camel4.mindspring.com>...

Quote
> Hi, I know that this question is probably VERY basic, but I can't
> figure it out... I have a DBEdit field in my form .. the datafield is
> named FILENAME and it contains a filename in it.

> I have an image field (called IMAGE1) that I'd like to load the file
> into (and display).

> I have the following:

> image1.stretch:=true;
> image1.Picture.LoadFromFile(dbedit1.datafield);

> I tried a whole lot of things and got different error messages... if
> the dbedit field contains TEST.BMP, I'd like for it to be loaded into
> image1...

> Can someone help me out?

> Thanks... Kevin

Other Threads