-
May 31st, 2012, 09:42 AM
#1
How Display Icon on Picture Box from Resource File
Hi,
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.
Code:
Imports System.Resources
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"
End If
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)))
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
picImage.Visible = True
End Sub
End Class
-
May 31st, 2012, 06:36 PM
#2
Re: How Display Icon on Picture Box from Resource File
0 is the first entry. You'll need the .SelectedIndex value (Proper Type necessary)
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|