English 中文(简体)
了解情况?
原标题:get name of picture?
if(pictureBox4.Image.ToString() == 
    ePRO_Decision_Tool.Properties.Resources.mod_onalertq.ToString())...

如何读写图像档案的名称(或资源)?

最佳回答

The image loaded in PictureBox is just an array of bytes, so to find out what is the filename you must fill the Tag property of PictureBox when any image loaded in it.

问题回答

<代码>Image物体仅含有图像二元数据。 您可以人工订立<代码>。 Tag Property of the Image to contained the file name (After You ve/61/7 the concept).

如果您使用<代码>Load()方法将图像输入<代码>PictureBox,该编码将更新<代码>。 履历

然后,可使用<条码>孔径Box4.ImageLocation进行比较。

http://msdn.microsoft.com/en-us/library/system.windows.forms.picture Box.imageplace.aspx”rel=“nofollow”>ImageLocation

我确信,“形象”没有结果,它没有暴露出哪里。

private void button1_Click(object sender, EventArgs e)
{
    openFileDialog1.FileName = "";
    openFileDialog1.Title = "Images";
    openFileDialog1.Filter = "JPG Image(*.jpg)|*.jpg|BMP Image(*.bmp)|*.bmp";
    openFileDialog1.ShowDialog();
    if (openFileDialog1.FileName.ToString() != "")
    {
        string imagePath = openFileDialog1.FileName.ToString();
        string imagepath = imagePath.ToString();
        imagepath = imagepath.Substring(imagepath.LastIndexOf("\"));
        imagepath = imagepath.Remove(0, 1);
    }
}

你们可以利用这一方式在图片箱中找到照片:

System.IO.Path.GetFileName(PictureBox.ImageLocation);

页 次 采用<代码>PictureBox.Image处理图像的方法。 Load(Image Path)

not working with load image directly from resource not working with load image by PictureBoc.Image = Image.FromFile(Image Path) because above methods(except Image.Load()) making Image.ImageLocation set to null

PictureBox.Image.Load("Image Path");
string imagepath = PictureBox.Image.ImageLocation.ToString();
                  imagepath = imagepath.Substring(imagepath.LastIndexOf("\"));
                  imagepath = imagepath.Remove(0, 1);

抵达 图一

 String getImageName = pictureBox1.Name;

        MessageBox.Show(getImageName);
            OpenFileDialog open =  new OpenFileDialog();
        open.Filter = "Image Files(* .jpg; * .jpeg; * .png;)|* .jpg; * .jpeg; * .png;";
        if(open.ShowDialog() == DialogResult.OK){
            
            piturebox1.Image = new Bitmap(open.FileName);
            String ImageName = Path.GetFileName(open.FileName);
        
        }

here is a simple way to get image name from picture box in c#:

string imgPath = pictureBox1.ImageLocation; 
string nameImage =imgPath.Substring(imgPath.LastIndexOf( \ )+1);




相关问题
Bring window to foreground after Mutex fails

I was wondering if someone can tell me what would be the best way to bring my application to the foreground if a mutex was not able to be created for a new instance. E.g.: Application X is running ...

How to start WinForm app minimized to tray?

I ve successfully created an app that minimizes to the tray using a NotifyIcon. When the form is manually closed it is successfully hidden from the desktop, taskbar, and alt-tab. The problem occurs ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

Handle DataTable.DataRow cell change event

I have a DataTable that has several DataColumns and DataRow. Now i would like to handle an event when cell of this DataRow is changed. How to do this in c#?

Apparent Memory Leak in DataGridView

How do you force a DataGridView to release its reference to a bound DataSet? We have a rather large dataset being displayed in a DataGridView and noticed that resources were not being freed after the ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

WPF-XAML window in Winforms Application

I have a Winforms application coded in VS C# 2008 and want to insert a WPF window into the window pane of Winforms application. Could you explain me how this is done.

热门标签