Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / September 2004

Tip: Looking for answers? Try searching our database.

picturebox's image

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
TS - 09 Sep 2004 20:58 GMT
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.
Herfried K. Wagner [MVP] - 09 Sep 2004 21:53 GMT
* "TS" <manofsteele@311.com> scripsit:
> 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.

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

Signature

M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/

"Jeffrey Tan[MSFT]" - 10 Sep 2004 06:55 GMT
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 a.s=Assembly.LoadFrom(@"your first assembly path");
               Type t=a.s.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
Signature

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

TS - 10 Sep 2004 22:22 GMT
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?

> Hi TS,
>
[quoted text clipped - 32 lines]
> Get Secure! - www.microsoft.com/security
> This posting is provided "as is" with no warranties and confers no rights.
"Jeffrey Tan[MSFT]" - 13 Sep 2004 08:13 GMT
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 a.s=Assembly.LoadFrom(@"You picturebox assembly");
    string[] res_name_arr=a.s.GetManifestResourceNames();
    foreach(string str in res_name_arr)
    {
        Console.WriteLine(str);
    }
    Type t=a.s.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
Signature

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

TS - 14 Sep 2004 21:45 GMT
thanks that did the trick

> Hi TS,
>
[quoted text clipped - 37 lines]
> Get Secure! - www.microsoft.com/security
> This posting is provided "as is" with no warranties and confers no rights.
"Jeffrey Tan[MSFT]" - 15 Sep 2004 02:57 GMT
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
Signature

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.