Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / August 2006

Tip: Looking for answers? Try searching our database.

How to use Resource files in VS 2005?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tom - 31 Aug 2006 21:15 GMT
This may seem a little strange, but in all my years of developing Windows
Forms apps, I've never really used Resource files; however, I would like
to start doing so in order to store icons, pictures, and most importantly,
error message strings in resource files so I don't have to go searching for
them inside the code (if I want them changed).

I know VS 2005 makes it MUCH easier to use and create resource files, but
in my few times I have tried I ended up not doing things right. Therefore,
does anyone know of any articles, tutorials, etc on how to createm use, and
ACCESS resource files (and items in them) in VS 2005? I am sure it is not
hard but a tutorial or something would go a long way in helping out.

Thanks a bunch.

To
Andrew Backer - 31 Aug 2006 22:46 GMT
Well, it depends on what you want to do with it.  I wasn't able to find
many good tutorials, but here is kinda what we use.

Go to 'add new item' and choose resource file, name it
MyResources.resx.  VS will generate some code for this, but there are
ways to load the resource manager by hand.   You can 'show all files'
on the project, and then look at the code it generates for the .resx
file to see how some of this works.

To get at a resource : MyResources.MyResources.res_name (returns
string/icon/etc)
To get the manager : MyResources.MyResources.ResourceManager

Loading it dynamically is a little harder, but not too bad.   You just
have to know what assembly it is in, mostly.  I wrote a utility class
that sits in the same dll as the resources, so I get my manager by
calling :

Dim resMgr as New ResourceManager(
   GetType(IconResources.IconResources).Name,
   Assembly.GetExecutingAssembly
)
// you could also use GetType(...).Assembly there.

After that you can call GetObject/GetResource on it, wrap it up with
nice functions, etc.  Do this is if you need to have someone specify
which resource manager to return by name, not type.   Also, look in the
code for the resx to see another way of loading the manager

So far it works pretty well for me.  I can not get access to this
resource file from another dll (in designer mode) but it works great
for all my dynamic stuff.

HTH

> This may seem a little strange, but in all my years of developing Windows
> Forms apps, I've never really used Resource files; however, I would like
[quoted text clipped - 11 lines]
>
> Tom

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.