May 31st, 2012, 09:42 AM
How Display Icon on Picture Box from Resource File
I am working on a Vb6 to VB.net migration application.I am not able to proceed in one place.I have a Resources.Resx file in my application in which some Icons are stored like "icoUS","icoCA" etc. And there is a combo box where some country names are listed.On selection of this combo box, the corresponding countrie's flag image should be dsiplayed on a picture box. Any help appreciated in this regard. The code , which I used is given below.
Public Class Form1
Private Sub lstCountries_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstCountries.SelectedIndexChanged
Dim cntryCode As String = String.Empty
If lstCountries.SelectedItem = "Australlia" Then
cntryCode = "AU"
ElseIf lstCountries.SelectedItem = "Brazil" Then
cntryCode = "BR"
ElseIf lstCountries.SelectedItem = "Canada" Then
cntryCode = "CA"
ElseIf lstCountries.SelectedItem = "Denmark" Then
cntryCode = "DE"
ElseIf lstCountries.SelectedItem = "United States" Then
cntryCode = "US"
Dim img As String = "ico" & cntryCode
picImage.Image = CType(My.Resources.ResourceManager.GetObject(img), Image)
'Dim res() As String = GetType(Form1).Assembly.GetManifestResourceNames()
' picImage.Image = New System.Drawing.Bitmap(GetType(ImageTest.My.Resources.Resource1).Assembly.GetManifestResourceStream(res(0)))
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
picImage.Visible = True
Tags for this Thread
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!