Image Display from Resources File - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Image Display from Resources File

sumithpssumithps Posts: 1Member
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

[/code]

Sign In or Register to comment.