p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 3.5 Basics (http://p2p.wrox.com/forumdisplay.php?f=351)
-   -   Priblem with picturebox and icon from .resx file (http://p2p.wrox.com/showthread.php?t=87603)

sumith May 24th, 2012 01:16 AM

Priblem with picturebox and icon from .resx file

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.

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
Catch ex As Exception

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.

sumith June 1st, 2012 03:12 AM

I resolved the issue.


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 10:29 AM.

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