Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
Image Display from Resources 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