我可以直接检索 TPicture 的文件名吗?

发布于 2024-08-13 14:26:09 字数 250 浏览 2 评论 0原文

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

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

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

我希望能够显示和编辑在上述过程中加载的文件名,我说得对吗?没有办法访问直接来自 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);

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

待天淡蓝洁白时 2024-08-20 14:26:09

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

var
  ImageFileName: string;


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

在您需要访问文件名的任何地方都可以看到该变量的位置声明 ImageFileName 变量。

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

var
  ImageFileName: string;


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

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

染年凉城似染瑾 2024-08-20 14:26:09

您可以将文件名存储在 Image1 的 Hint 属性中。

如果您还没有使用它。按照预期或出于其他目的......我发现这个属性相当混乱:)

You can store the filename in the Hint property of Image1.

if you don't already use it. As intended or for another purpouse... I find this property pretty promiscuous :)

小霸王臭丫头 2024-08-20 14:26:09

您可以将文件名存储在 Image1 的 TagString 属性中。

如果您还没有使用它。

(在 Firemonkey 中,而不是 VCL)

You can store the filename in the TagString property of Image1.

if you don't already use it.

(in Firemonkey, not VCL)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文