.NETGURU
picturebox's image
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.windowsforms.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

TS
how do i tell where i got the image for a picturebox control? I need to
locate its file for use in my web app.

Reply to this message...
 
    
Herfried K. Wagner [MVP] (VIP)
* "TS" <Click here to reveal e-mail address> scripsit:
[Original message clipped]

This information is not stored for the picturebox's 'Image' property.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Reply to this message...
 
    
Jeffrey Tan[MSFT] (VIP)
Hi TS,

Based on my understanding, you want to re-use the image in one assembly in
another application.

Actually, when you specify the a picture for the PictureBox.Image property
in Property browser, the picture will be embed in the Form class as
resource, it will contain no path information about the picture on the disk.

For your issue, I think you may retrieve the image resource directly from
the assembly and reuse for your second picturebox, code like this:
private void button1_Click(object sender, System.EventArgs e)
{
    Assembly ass=Assembly.LoadFrom(@"your first assembly path");
Type t=ass.GetType("accesstest.Form1");
//GetType("applicationname.classname")

    System.Resources.ResourceManager resources = new
System.Resources.ResourceManager(t);
    this.pictureBox1.Image =
((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
//resource name
}
=========================================
Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Reply to this message...
 
    
TS
well i actually need to give someone the image file. Do you think i should
do what you have here, and then save it to a file?

""Jeffrey Tan[MSFT]"" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Jeffrey Tan[MSFT] (VIP)
Hi TS,

Thanks for your feedback.

Yes, because once you set an image for the picturebox in property browser,
this image will be embeded in the assembly as resource, it will has no
relation with the picture on the disk, and it makes no sense for the
resource to store the image path information. Also, the user may have
deleted , modified or moved the original image on the disk.

So for your issue, I think you may retrieve the image resource from the
assembly and save it again to the disk. Like this:
private void button1_Click(object sender, System.EventArgs e)
{
    Assembly ass=Assembly.LoadFrom(@"You picturebox assembly");
    string[] res_name_arr=ass.GetManifestResourceNames();
    foreach(string str in res_name_arr)
    {
        Console.WriteLine(str);
    }
    Type t=ass.GetType("accesstest.Form1");

    System.Resources.ResourceManager resources = new
System.Resources.ResourceManager(t);
    System.Drawing.Image
img=(System.Drawing.Image)(resources.GetObject("pictureBox1.Image"));
    img.Save(@"D:\\savedpic.bmp");
}
=========================================
Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Reply to this message...
 
    
TS
thanks that did the trick

""Jeffrey Tan[MSFT]"" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Jeffrey Tan[MSFT] (VIP)
Hi TS,

Thanks for your feedback.

I am glad my reply makes sense to you, if you need further help, please
feel free to tell me, I will help you. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Reply to this message...
 
 
System.Console
System.Drawing.Image
System.EventArgs
System.Reflection.Assembly
System.Resources.ResourceManager
System.Windows.Forms.PictureBox




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification