PC Review


Reply
Thread Tools Rate Thread

Assign a resource to a Picture Box programatically

 
 
Jürgen Heyn
Guest
Posts: n/a
 
      4th May 2007
Good afternoon,

I would like to display a bitmap in a PictureBox which is stored in a
resource file.

The following code works perfectly:
picUser.Image = My.Resources.ResUserIcon01.x48_Crewmember

From a database the application retrieves a string:
"x48_Crewmember" (or "ResUserIcon01.x48_Crewmember")

How can I display the bitmap in a PictureBox using this string?

I could do ist with the following:
Select Case True
Case strBildname = "x48_Crewmember"
picUser.Image = My.Resources.ResUserIcon01.x48_Crewmember
....
End Select

Because of the number of bitmaps there must be a more elegant way.
Thank you for any hint.
Best regards
Jürgen Heyn, Wilhelmshaven, Germany


 
Reply With Quote
 
 
 
 
James Wragg
Guest
Posts: n/a
 
      11th Oct 2010
Hey,

Forgive me for bump, but I spent forever searching on google for this answer and could never find it. So I spent more time trying to figure it out for myself, and I have managed to do it!

Solution:

picuser.Image = My.Resources.ResourceManager.GetObject("RESOUCE NAME AS STRING")

Peace.

> On Friday, May 04, 2007 10:14 AM J?rgen Heyn wrote:


> Good afternoon,
>
> I would like to display a bitmap in a PictureBox which is stored in a
> resource file.
>
> The following code works perfectly:
> picUser.Image = My.Resources.ResUserIcon01.x48_Crewmember
>
> From a database the application retrieves a string:
> "x48_Crewmember" (or "ResUserIcon01.x48_Crewmember")
>
> How can I display the bitmap in a PictureBox using this string?
>
> I could do ist with the following:
> Select Case True
> Case strBildname = "x48_Crewmember"
> picUser.Image = My.Resources.ResUserIcon01.x48_Crewmember
> ...
> End Select
>
> Because of the number of bitmaps there must be a more elegant way.
> Thank you for any hint.
> Best regards
> J?rgen Heyn, Wilhelmshaven, Germany



> Submitted via EggHeadCafe - Software Developer Portal of Choice
> ASP.NET HttpPostedFile Image Resizer
> http://www.eggheadcafe.com/tutorials...e-resizer.aspx

 
Reply With Quote
 
James Wragg
Guest
Posts: n/a
 
      11th Oct 2010
Hey,

Forgive me for bump, but I spent forever searching on google for this answer and could never find it. So I spent more time trying to figure it out for myself, and I have managed to do it!

Solution:

picuser.Image = My.Resources.ResourceManager.GetObject("RESOUCE NAME AS STRING")

Peace.

> On Friday, May 04, 2007 10:14 AM J?rgen Heyn wrote:


> Good afternoon,
>
> I would like to display a bitmap in a PictureBox which is stored in a
> resource file.
>
> The following code works perfectly:
> picUser.Image = My.Resources.ResUserIcon01.x48_Crewmember
>
> From a database the application retrieves a string:
> "x48_Crewmember" (or "ResUserIcon01.x48_Crewmember")
>
> How can I display the bitmap in a PictureBox using this string?
>
> I could do ist with the following:
> Select Case True
> Case strBildname = "x48_Crewmember"
> picUser.Image = My.Resources.ResUserIcon01.x48_Crewmember
> ...
> End Select
>
> Because of the number of bitmaps there must be a more elegant way.
> Thank you for any hint.
> Best regards
> J?rgen Heyn, Wilhelmshaven, Germany



>> On Monday, October 11, 2010 1:00 PM James Wragg wrote:


>> Hey,
>>
>>
>>
>> Forgive me for bump, but I spent forever searching on google for this answer and could never find it. So I spent more time trying to figure it out for myself, and I have managed to do it!
>>
>>
>>
>> Solution:
>>
>>
>>
>> picuser.Image = My.Resources.ResourceManager.GetObject("RESOUCE NAME AS STRING")
>>
>>
>>
>> Peace.



>> Submitted via EggHeadCafe - Software Developer Portal of Choice
>> Silverlight 4 Martin Fractals with WriteableBitmapEx
>> http://www.eggheadcafe.com/tutorials...ebitmapex.aspx

 
Reply With Quote
 
James Wragg
Guest
Posts: n/a
 
      11th Oct 2010
Hey,

Forgive me for bump, but I spent forever searching on google for this answer and could never find it. So I spent more time trying to figure it out for myself, and I have managed to do it!

Solution:

picuser.Image = My.Resources.ResourceManager.GetObject("RESOUCE NAME AS STRING")

Peace.

> On Friday, May 04, 2007 10:14 AM J?rgen Heyn wrote:


> Good afternoon,
>
> I would like to display a bitmap in a PictureBox which is stored in a
> resource file.
>
> The following code works perfectly:
> picUser.Image = My.Resources.ResUserIcon01.x48_Crewmember
>
> From a database the application retrieves a string:
> "x48_Crewmember" (or "ResUserIcon01.x48_Crewmember")
>
> How can I display the bitmap in a PictureBox using this string?
>
> I could do ist with the following:
> Select Case True
> Case strBildname = "x48_Crewmember"
> picUser.Image = My.Resources.ResUserIcon01.x48_Crewmember
> ...
> End Select
>
> Because of the number of bitmaps there must be a more elegant way.
> Thank you for any hint.
> Best regards
> J?rgen Heyn, Wilhelmshaven, Germany



>> On Monday, October 11, 2010 1:00 PM James Wragg wrote:


>> Hey,
>>
>>
>>
>> Forgive me for bump, but I spent forever searching on google for this answer and could never find it. So I spent more time trying to figure it out for myself, and I have managed to do it!
>>
>>
>>
>> Solution:
>>
>>
>>
>> picuser.Image = My.Resources.ResourceManager.GetObject("RESOUCE NAME AS STRING")
>>
>>
>>
>> Peace.



>>> On Monday, October 11, 2010 1:02 PM James Wragg wrote:


>>> Hey,
>>>
>>>
>>>
>>> Forgive me for bump, but I spent forever searching on google for this answer and could never find it. So I spent more time trying to figure it out for myself, and I have managed to do it!
>>>
>>>
>>>
>>> Solution:
>>>
>>>
>>>
>>> picuser.Image = My.Resources.ResourceManager.GetObject("RESOUCE NAME AS STRING")
>>>
>>>
>>>
>>> Peace.



>>> Submitted via EggHeadCafe - Software Developer Portal of Choice
>>> Lucene.Net Indexing Searching Entry Level Tutorial
>>> http://www.eggheadcafe.com/tutorials...-tutorial.aspx

 
Reply With Quote
 
James Wragg
Guest
Posts: n/a
 
      11th Oct 2010
I appologise for the spam. I registered as I was posting, and my browser resubmitted post data several times.

Submitted via EggHeadCafe - Software Developer Portal of Choice
Book Review: Google Analytics
http://www.eggheadcafe.com/tutorials...analytics.aspx
 
Reply With Quote
 
New Member
Join Date: Jan 2012
Posts: 1
 
      13th Jan 2012
Thanks for this! I too spent many minutes trying to Google this, but unlike you I actually found your post so it saved me hours of possibly tedious work. :P
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Programatically select which resource file to load from Michael Microsoft ASP .NET 1 27th Aug 2008 03:06 AM
How to automatically assign resource strings =?Utf-8?B?UG9udGlNYXg=?= Microsoft ASP .NET 0 29th Jun 2004 08:24 PM
How to assign the DataKeys property of the datagrid programatically from a datasource? Alex Microsoft ASP .NET 0 23rd Apr 2004 09:10 PM
Programatically Assign Outlook Task Todd Lemen Microsoft Outlook VBA Programming 11 3rd Mar 2004 01:32 PM
Accessing Resource information programatically =?Utf-8?B?RGVuNDI=?= Microsoft Windows 2000 Macintosh 5 7th Nov 2003 08:48 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:52 PM.