p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/)
-   ASP.NET 3.5 Basics (http://p2p.wrox.com/asp-net-3-5-basics-351/)
-   -   Priblem with picturebox and icon from .resx file (http://p2p.wrox.com/asp-net-3-5-basics/87603-priblem-picturebox-icon-resx-file.html)

sumith May 24th, 2012 02:16 AM

Priblem with picturebox and icon from .resx file
 
Hi,

I am working on a vb6 to vb.net migration project using VS 3.5. In my application, there is .resx file and some icons are there in this file (eg: icoIN,icoUS etc). On click of a checked listbox (which is filled with country names), the particular country flag should be displayed on a picture box control. The image of country flag is taken from the .resx file.I tried with the following code.
Code:

Try
Dim iconStream As Stream = Nothing
Dim bmp As Bitmap = Nothing
'lstcountries is the checkedlistbox and imgcountry is the picturebox
If lstcountries.getitemchecked(EventArgs.index) Then
imgcountry.visible = True
iconStream = System.Reflection.Assembly.GetExecutingAssembly.GetManifestResourceStream("icoIN")
bmp =
New Bitmap(iconStream)
imgcountry.image = bmp
EndIf
Catch ex As Exception
EndTry

but the iconstream is returning an empty value and the picture box not displaying any image. Can anybody help me on this issue.
Any help appreciated.
Regards,
Sumith.

sumith June 1st, 2012 04:12 AM

Hi,
I resolved the issue.

Code:

Dim bitmap As Bitmap
bitmap = CType(My.Resources.ResourceManager.GetObject("B"), Icon).ToBitmap
PictureBox1.Image = CType(bitmap, Image)

where, B is the name of the icon in the resource file.


All times are GMT -4. The time now is 01:39 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
2013 John Wiley & Sons, Inc.