|
-
Oct 16th, 2006, 11:02 AM
#1
Thread Starter
New Member
Regarding the usage of resource file in VB.NET
Hi,
i want to know how to store a icons and images in a resource file. Also the method to load it from there and display it in picturebox in vb.net.
Thanks,
Ganesh
-
Oct 16th, 2006, 11:14 AM
#2
Re: Regarding the usage of resource file in VB.NET
Here something I knocked up to control getting them out easily.
VB Code:
'Somewhere public
Friend MyResFile As New Resources.ResourceManager("resMyResFile", GetType(modNameOfModuleDeclaredIn).Assembly)
Friend Function LoadResString(ByVal ResourceNumber As Integer) As String
Dim strReturn As String
strReturn = MyResFile.GetString(ResourceNumber.ToString)
If strReturn Is Nothing Then
strReturn = ""
End If
Return strReturn
End Function
Friend Function LoadResPicture(ByVal ResourceString As String) As System.Drawing.Image
Return CType(MyResFile.GetObject(ResourceString), System.Drawing.Image)
End Function
Last edited by Grimfort; Oct 16th, 2006 at 11:19 AM.
-
Oct 16th, 2006, 11:56 AM
#3
Re: Regarding the usage of resource file in VB.NET
if you are using VB.NET 2005, they have made it much easier to use resource files by way of the My namespace...
Say you added an image to your project as a resource, and the image was of a house, which you gave the label "HOUSE" you would access it in code like
VB Code:
picturebox1.Image = my.Resources.HOUSE
-
Oct 16th, 2006, 11:26 PM
#4
Thread Starter
New Member
Re: Regarding the usage of resource file in VB.NET
Hi,
Thanks for your replies.
whether is it possible to assign a id to each icon or image in resource file and whether we can get the image or icon using that id in VB.NET.
Thanks,
Ganesh
-
Oct 17th, 2006, 08:17 AM
#5
Re: Regarding the usage of resource file in VB.NET
-
Oct 17th, 2006, 08:27 AM
#6
Thread Starter
New Member
Re: Regarding the usage of resource file in VB.NET
-
Oct 17th, 2006, 08:29 AM
#7
Re: Regarding the usage of resource file in VB.NET
then you can do it just how I said in post #3
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
|