从C#中的flowlayout面板读取图像名称 [英] Read image name from flowlayout panel in C#

查看:52
本文介绍了从C#中的flowlayout面板读取图像名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友,

我正在c#中使用Flowlayout面板动态显示图像列表.
图像也在显示.
图像计数可能会有所不同,这仅在运行时才知道.

这就是我想要的.....

1)是否需要知道在Flowlayout面板中用户单击了哪个图像?
2)然后需要读取所选图像文件的文件名.

请尽快帮助我.

预先感谢.

Hi Friends,

I am using Flowlayout panel in c# to display list of images dynamically.
Images are displaying as well.
Images count may vary, which is known only on run time.

Here is what I want.....

1) Need to know, in Flowlayout panel, which image is clicked by the user?
2) Then need to read the file name of selected image file.

Please help me ASAP.

Thanks in advance.

推荐答案



我认为这可以解决您的问题:

Hi,

I think this might solve your problem:

foreach (var item in this.flowLayoutPanel1.Controls)
{
    ((PictureBox)item).Click += (sender, e) =>
        {
            // read the file name
            string location = ((PictureBox)sender).ImageLocation;

            MessageBox.Show(string.Format("Child Control Names: {0} - Image Location: {1}", ((PictureBox)sender).Name, location));
        };
}



亲切的问候,



Kind regards,


这篇关于从C#中的flowlayout面板读取图像名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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