473,411 Members | 2,085 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

Looping Through Application Settings

I have a Windows Form application with several application settings set. How
is it possible for me to loop through those settings? Is it possible at all?

Thank you

Jul 31 '07 #1
7 11672
<< Is it possible at all? >>

No - this is logically and technically impossible.

"RHPT" <RH**@online.nospamwrote in message
news:71**********************************@microsof t.com...
>I have a Windows Form application with several application settings set.
How
is it possible for me to loop through those settings? Is it possible at
all?

Thank you

Jul 31 '07 #2
MWS
On Jul 31, 12:20 pm, RHPT <R...@online.nospamwrote:
I have a Windows Form application with several application settings set. How
is it possible for me to loop through those settings? Is it possible at all?

Thank you
NameValueCollection settings;
settings = System.Configuration.ConfigurationManager.AppSetti ngs;

foreach (string keyname in settings.AllKeys)
{
messagebox.show(keyname)
{

Jul 31 '07 #3
Hi,

As MWS suggested, the Settings is of type NameValueCollection and you can
use its AllKeys to iterate.

I'm not sure if this is what you wanted. Please feel free to let us know if
you have further questions. Thanks.
Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 1 '07 #4


"MWS" wrote:
>
NameValueCollection settings;
settings = System.Configuration.ConfigurationManager.AppSetti ngs;

foreach (string keyname in settings.AllKeys)
{
messagebox.show(keyname)
{
This returns the error "The type or namespace name 'ConfigurationManager'
does not exist in the namespace 'System.Configuration'. I have to use
System.Configuration.ConfigurationSettings.AppSett ings.

And that does not return any of my app settings.

Aug 1 '07 #5
Hello RHPT,
"MWS" wrote:
>NameValueCollection settings;
settings = System.Configuration.ConfigurationManager.AppSetti ngs;
foreach (string keyname in settings.AllKeys)
{
messagebox.show(keyname)
{
This returns the error "The type or namespace name
'ConfigurationManager' does not exist in the namespace
'System.Configuration'. I have to use
System.Configuration.ConfigurationSettings.AppSett ings.

And that does not return any of my app settings.
You need to add a reference to the System.Configuration to your project.
These classes used to reside in the .NET Core Assembly, but were moved to
a separate assembly for .NET 2.0.

Jesse
Aug 1 '07 #6
Hi,

Are you using the Client Settings (created with the Settings Designer)? In
other words, you have a strong typed settings class and you access the
settings via strong typed property name:

Settings.Default.MyProperty
If this is the case, then the AppSettings will not help here since it's
using different approaches.
To get the property name list, you can use Settings.Default.Properties to
iterate them:

foreach (SettingsProperty sp in Settings.Default.Properties)
{
Console.WriteLine(sp.Name);
}

After you get the property name, then you can use reflection on the
Settings.Default object to get the property value. You can also use
SettingsProperty.DefaultValue to get the default value when you input in
the settings designer.
Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 2 '07 #7

""Walter Wang [MSFT]"" wrote:
Hi,

Are you using the Client Settings (created with the Settings Designer)? In
other words, you have a strong typed settings class and you access the
settings via strong typed property name:

Settings.Default.MyProperty
If this is the case, then the AppSettings will not help here since it's
using different approaches.
To get the property name list, you can use Settings.Default.Properties to
iterate them:

foreach (SettingsProperty sp in Settings.Default.Properties)
{
Console.WriteLine(sp.Name);
}

After you get the property name, then you can use reflection on the
Settings.Default object to get the property value. You can also use
SettingsProperty.DefaultValue to get the default value when you input in
the settings designer.

Thank you. This is what I was looking for. I should have asked my question
better.
Aug 2 '07 #8

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

Similar topics

8
by: Google Mike | last post by:
I need an Application object replacement. I was creating my own using shared memory -- shm* API in PHP. I was doing fine for 6 months until it just got too fat, I guess, and the RH9 Linux server...
7
by: Chris Thunell | last post by:
I'm trying to loop through an exchange public folder contact list, get some information out of each item, and then put it into a vb.net datatable. I run though the code and all works fine until i...
1
by: Cristian | last post by:
Hi I have some trouble (on only one developer computer) with the application settings functions... I have posted to the Microsoft.Public.vstudio.setup group but they couldn't help me and asked...
2
by: Bob | last post by:
The my.settings name space is easy to use to modify User settings from within code, but the application settings can't seem to be modified that easily. I want the user to be able to modify some of...
3
by: Jon Slaughter | last post by:
I wrote an app that needed to save settings such as colors, fonts, etc... after hours of trying to use ConfigurationManager and AppSettings along with a few other things I finally found that I...
3
by: xycos | last post by:
Hello. I apologize for asking this question as the information I need is availible via the MSDN library, however I cannot seemt o understand what I need to do, so I'm asking here. I have created...
0
by: steve | last post by:
I am using vb.net 2005 Express Edition. Application Settings would be a very useful thing, as a global program database that persists; if only it would work! Does anyone know a hack or a...
10
by: afromanam | last post by:
Regards, Please help What I'm trying to do is this: (and I can't use reports since I must export to Excel) I export some queries to different tabs in an excel workbook I then loop through...
1
by: BobLewiston | last post by:
I tried to compile a Windows Forms Application in Visual C# 2008 Express with this source code from the CSharpSchool tutorial at Programmer's Heaven:using System; using System.Windows.Forms; using...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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...

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.