可以直接检索TPicture的文件名吗? [英] Can I retrieve Filename for TPicture directly?

查看:122
本文介绍了可以直接检索TPicture的文件名吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Delphi应用程序,使用TImage显示图像。

I have a Delphi application which displays an image using a TImage.

图像的位置存储在数据库中,并在加载时检索并直接使用代码类似如下:

The location of the image is stored in a database and retrieved on load and set directly using code similar to below:

Image1.Picture.LoadFromFile(Query1.FieldByName('image').AsString);

我想要能够显示和编辑在上面加载的文件名,我是对的没有办法直接从TImage组件访问,我需要分开存储文件。

I want to be able to display and edit the Filename being loaded during the above, am I right that there is no way to access that directly from the TImage component and that I will need to store the filename separately?

推荐答案

不,没有。您可以自己存储它。

No, there isn't. You can store it yourself, though.


var
  ImageFileName: string;


begin
  ImageFileName := Query1.FieldByName('image').AsString;
  Image1.Picture.LoadFromFile(ImageFileName);
end;

在需要访问文件名称的地方可以看到ImageFileName变量。

Declare the ImageFileName variable at a place where it will be visible everywhere you need access to the file name.

这篇关于可以直接检索TPicture的文件名吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆