473,748 Members | 2,528 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Retrieving a resource name/value.

Hi folks,
Consider a string that's defined under VS2005 resource editor as
myField with the value of myValue. To access the value, I could easily
use the Properties.Reso urces class, for example:

global::myNameS pace.Properties .Resources.myFi eld

However, I would like to retreive it's string representation of the
field's name, i.e., the "myField". How am I supposed to do that?

The second question is that is there anyway to keep a "name/value"
collection within a resource file?

Any help would be highly appreciated,

Cheers,
Mehdi

Jul 12 '06 #1
1 2537
Hi Mehdi,
global::myNameS pace.Properties .Resources.myFi eld
However, I would like to retreive it's string representation of the
field's name, i.e., the "myField". How am I supposed to do that?
Hard-coding the string into your program might be your best bet if you only
want a limited number of strings. After all, the string "myField" is a
constant that you define at design-time.

I don't see how you could possibly retrieve the key name at runtime without
using the key name to find that resource item, but if you want to retrieve
all of the key names in your Resources object try the following code:

foreach (DictionaryEntr y resourceEntry in
Properties.Reso urces.ResourceM anager.GetResou rceSet(
System.Globaliz ation.CultureIn fo.CurrentUICul ture, true, true))
{
string keyName = resourceEntry.K ey;
}
The second question is that is there anyway to keep a "name/value"
collection within a resource file?
I can think of a few options:

1. Serialize a Dictionary, Base64 encode it, then hard-code the value into
the resource grid.
(To read it you must unencode it and deserialize it back into a
Dictionary)
2. Use a delimited format like key=value[,key=value...] and parse the
resource into a Dictionary at runtime.
3. For option #2 you could use = and & as delimiters and encode each key and
value as if they were urls.
4. Use an xml file instead of an embedded resource.
5. Use a database.

- Dave Sexton

"mehdi_mous avi" <me***********@ gmail.comwrote in message
news:11******** **************@ p79g2000cwp.goo glegroups.com.. .
Hi folks,
Consider a string that's defined under VS2005 resource editor as
myField with the value of myValue. To access the value, I could easily
use the Properties.Reso urces class, for example:

global::myNameS pace.Properties .Resources.myFi eld

However, I would like to retreive it's string representation of the
field's name, i.e., the "myField". How am I supposed to do that?

The second question is that is there anyway to keep a "name/value"
collection within a resource file?

Any help would be highly appreciated,

Cheers,
Mehdi

Jul 12 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1767
by: Arjen | last post by:
Hello, I have 2 resource files. The resource files have both inside the name field values. I want to select from the first resource file the records where the name field haves a value between 1 and 25. Now I am doing this: XmlDocument xdResx = new XmlDocument(); xdResx.Load("Resources.resx");
7
16736
by: Robert W. | last post by:
I think I'm going insane, but thought I'd check with you all first before I get myself commited! Here's a method I've built to retrieve an image: public static Image GetImage(string imageBaseName, ref int imageNum) { string fullName = ""; Bitmap image = null; Stream stream;
1
4023
by: Namratha Shah \(Nasha\) | last post by:
Hi All, This is a resource file generation tool which converts an xml based resource formats to .net resource file i.e. (.resources) and vice-versa. Today we will see how we will generate ==> .txt files from .resources or .resx files. ==> .resources files from text or .resx files.
0
2981
by: Mythran | last post by:
I wrote some code that is supposed to enumerate through the specified file's win32 resources and return a string-array of all icon names. When it runs, it returns a string-array with a bunch of numbers in sequential order (1-55 when ran against iexplore.exe). When I open up iexplore.exe in Visual Studio, I see 23 icons. Each icon has 1 or more sizes of the icon...I'm assuming that there are, in fact, 55 icon resources in iexplore.exe,...
1
2114
by: Chukkalove | last post by:
I originally created several "copy" resource reader classes which worked great individually, but after I converted them into an parent class with children they no longer find the resources. Each project contains its own reader class and resource .resx file from where a string or image is read. Can someone tell me what I need to do to get them to work please. I attach code. Im not sure if it's because the derived classes are in...
10
3699
by: Girish | last post by:
Hi Everyone, I am passing a form to a php script for further processing. I am able to retrieve the last value set for that given form variable using $variable=$_REQUEST;
5
2777
by: Daniel | last post by:
Hey guys When you hook an event (c# 2.0 syntax): myEvent += MyMethodToFire; You need to also unsubscribe it to avoid a resource leak so that the object it is in gets garbage collected like so : myEvent -= MyMethodToFire; That's all fine, but when you use visual studio to create events for objects it never creates an unsubscribing reference, so is it puting in resource leaks? Or is this being cleared somewhere that i am not seeing?
0
3393
bmallett
by: bmallett | last post by:
First off, i would like to thank everyone for any and all help with this. That being said, I am having a problem retrieving/posting my dynamic form data. I have a form that has multiple options within options. I have everything being dynamically named from the previously dynamically named element. (I hope this makes sense.) I am not able to retrieve any of the dynamically created values. I can view them on the source page but can't pull them...
0
8995
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8832
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9561
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9381
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9254
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6799
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6078
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3316
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.