Search:
Namespaces
Discussions
.NET v1.1
Feedback
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
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com