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
Printable View
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
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
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
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
Are you using VB 2005?
yes i am using VS2005.
then you can do it just how I said in post #3