Hi,
I have a windows form app which would benefit from the new application
settings support in VS2005.
Say that my form has a single textbox on it. When the form closes I would
like to save the text in that textbox as part as the user level application
settings. When the application restarts I would like that text to be
restored to the textbox.
Because I am not using a built-in property on my form does this mean that I
cannot use the designer to add my setting?
Or, do I *have* to create a custom class derived from
ApplicationSett ingsBase and manage everything myself?
No matter how I approach this I cannot seem to get my settings to
"automagica lly" restore their values at app startup.
Any pointers would be greatly appreciated!
BT 7 2439
Just to provide more information:
Using the designer I added the following setting (using the designer)
Name: MySetting
Type: string
Scope: User
Value: Initial value
public Form1()
{
InitializeCompo nent();
// Load the data from user.config
textBox1.Text = Properties.Sett ings.Default.My Setting;
}
private void Form1_FormClosi ng(object sender, FormClosingEven tArgs e)
{
// Save any of my settings
Properties.Sett ings.Default.Sa ve();
}
My problem is that textBox1.Text MySetting is not being restored correctly -
it always reverts to its "initial" value.
-BT
"Bit Twiddler" <bi***********@ hotmail.com> wrote in message
news:%2******** *******@tk2msft ngp13.phx.gbl.. . Hi,
I have a windows form app which would benefit from the new application settings support in VS2005.
Say that my form has a single textbox on it. When the form closes I would like to save the text in that textbox as part as the user level application settings. When the application restarts I would like that text to be restored to the textbox.
Because I am not using a built-in property on my form does this mean that I cannot use the designer to add my setting?
Or, do I *have* to create a custom class derived from ApplicationSett ingsBase and manage everything myself?
No matter how I approach this I cannot seem to get my settings to "automagica lly" restore their values at app startup.
Any pointers would be greatly appreciated!
BT
Ok, I figured it out - of course it was user error.
I was not updating the settings when the text of the textbox was actually
changed! :(
private void textBox1_TextCh anged(object sender, EventArgs e)
{
Properties.Sett ings.Default.My Setting = textBox1.Text;
}
-BT
"Bit Twiddler" <bi***********@ hotmail.com> wrote in message
news:O$******** ******@TK2MSFTN GP11.phx.gbl... Just to provide more information:
Using the designer I added the following setting (using the designer) Name: MySetting Type: string Scope: User Value: Initial value
public Form1() { InitializeCompo nent(); // Load the data from user.config textBox1.Text = Properties.Sett ings.Default.My Setting; }
private void Form1_FormClosi ng(object sender, FormClosingEven tArgs e) { // Save any of my settings Properties.Sett ings.Default.Sa ve(); }
My problem is that textBox1.Text MySetting is not being restored correctly - it always reverts to its "initial" value.
-BT
"Bit Twiddler" <bi***********@ hotmail.com> wrote in message news:%2******** *******@tk2msft ngp13.phx.gbl.. . Hi,
I have a windows form app which would benefit from the new application settings support in VS2005.
Say that my form has a single textbox on it. When the form closes I would like to save the text in that textbox as part as the user level application settings. When the application restarts I would like that text to be restored to the textbox.
Because I am not using a built-in property on my form does this mean that I cannot use the designer to add my setting?
Or, do I *have* to create a custom class derived from ApplicationSett ingsBase and manage everything myself?
No matter how I approach this I cannot seem to get my settings to "automagica lly" restore their values at app startup.
Any pointers would be greatly appreciated!
BT
BT,
Why not use data binding and just bind the value of the textbox to the
MySetting property on the object? This would probably be much easier.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Bit Twiddler" <bi***********@ hotmail.com> wrote in message
news:%2******** *******@TK2MSFT NGP15.phx.gbl.. . Ok, I figured it out - of course it was user error.
I was not updating the settings when the text of the textbox was actually changed! :(
private void textBox1_TextCh anged(object sender, EventArgs e) { Properties.Sett ings.Default.My Setting = textBox1.Text; } -BT
"Bit Twiddler" <bi***********@ hotmail.com> wrote in message news:O$******** ******@TK2MSFTN GP11.phx.gbl... Just to provide more information:
Using the designer I added the following setting (using the designer) Name: MySetting Type: string Scope: User Value: Initial value
public Form1() { InitializeCompo nent(); // Load the data from user.config textBox1.Text = Properties.Sett ings.Default.My Setting; }
private void Form1_FormClosi ng(object sender, FormClosingEven tArgs e) { // Save any of my settings Properties.Sett ings.Default.Sa ve(); }
My problem is that textBox1.Text MySetting is not being restored correctly - it always reverts to its "initial" value.
-BT
"Bit Twiddler" <bi***********@ hotmail.com> wrote in message news:%2******** *******@tk2msft ngp13.phx.gbl.. . Hi,
I have a windows form app which would benefit from the new application settings support in VS2005.
Say that my form has a single textbox on it. When the form closes I would like to save the text in that textbox as part as the user level application settings. When the application restarts I would like that text to be restored to the textbox.
Because I am not using a built-in property on my form does this mean that I cannot use the designer to add my setting?
Or, do I *have* to create a custom class derived from ApplicationSett ingsBase and manage everything myself?
No matter how I approach this I cannot seem to get my settings to "automagica lly" restore their values at app startup.
Any pointers would be greatly appreciated!
BT
Thank you for the suggestion Nicholas and in fact I was just trying to
figure out the correct way to do that.
I am not sure how to create the binding between
Properties.Sett ings.Default.My Setting and the Text property of the textBox1
textbox.
textBox1.DataBi ndings.Add("Tex t", Properties.Sett ings, "Default.MySett ing
");
Is this correct?
Thanks!
BT
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:uU******** ******@TK2MSFTN GP11.phx.gbl... BT,
Why not use data binding and just bind the value of the textbox to the MySetting property on the object? This would probably be much easier.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard. caspershouse.co m
"Bit Twiddler" <bi***********@ hotmail.com> wrote in message news:%2******** *******@TK2MSFT NGP15.phx.gbl.. . Ok, I figured it out - of course it was user error.
I was not updating the settings when the text of the textbox was actually changed! :(
private void textBox1_TextCh anged(object sender, EventArgs e) { Properties.Sett ings.Default.My Setting = textBox1.Text; } -BT
"Bit Twiddler" <bi***********@ hotmail.com> wrote in message news:O$******** ******@TK2MSFTN GP11.phx.gbl... Just to provide more information:
Using the designer I added the following setting (using the designer) Name: MySetting Type: string Scope: User Value: Initial value
public Form1() { InitializeCompo nent(); // Load the data from user.config textBox1.Text = Properties.Sett ings.Default.My Setting; }
private void Form1_FormClosi ng(object sender, FormClosingEven tArgs e) { // Save any of my settings Properties.Sett ings.Default.Sa ve(); }
My problem is that textBox1.Text MySetting is not being restored correctly - it always reverts to its "initial" value.
-BT
"Bit Twiddler" <bi***********@ hotmail.com> wrote in message news:%2******** *******@tk2msft ngp13.phx.gbl.. . Hi,
I have a windows form app which would benefit from the new application settings support in VS2005.
Say that my form has a single textbox on it. When the form closes I would like to save the text in that textbox as part as the user level application settings. When the application restarts I would like that text to be restored to the textbox.
Because I am not using a built-in property on my form does this mean that I cannot use the designer to add my setting?
Or, do I *have* to create a custom class derived from ApplicationSett ingsBase and manage everything myself?
No matter how I approach this I cannot seem to get my settings to "automagica lly" restore their values at app startup.
Any pointers would be greatly appreciated!
BT
BT,
Almost. I think you want:
textBox1.DataBi ndings.Add("Tex t", Properties.Sett ings.Default, "MySetting" );
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Bit Twiddler" <bi***********@ hotmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. .. Thank you for the suggestion Nicholas and in fact I was just trying to figure out the correct way to do that.
I am not sure how to create the binding between Properties.Sett ings.Default.My Setting and the Text property of the textBox1 textbox.
textBox1.DataBi ndings.Add("Tex t", Properties.Sett ings, "Default.MySett ing ");
Is this correct?
Thanks! BT
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in message news:uU******** ******@TK2MSFTN GP11.phx.gbl... BT,
Why not use data binding and just bind the value of the textbox to the MySetting property on the object? This would probably be much easier.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard. caspershouse.co m
"Bit Twiddler" <bi***********@ hotmail.com> wrote in message news:%2******** *******@TK2MSFT NGP15.phx.gbl.. . Ok, I figured it out - of course it was user error.
I was not updating the settings when the text of the textbox was actually changed! :(
private void textBox1_TextCh anged(object sender, EventArgs e) { Properties.Sett ings.Default.My Setting = textBox1.Text; } -BT
"Bit Twiddler" <bi***********@ hotmail.com> wrote in message news:O$******** ******@TK2MSFTN GP11.phx.gbl... Just to provide more information:
Using the designer I added the following setting (using the designer) Name: MySetting Type: string Scope: User Value: Initial value
public Form1() { InitializeCompo nent(); // Load the data from user.config textBox1.Text = Properties.Sett ings.Default.My Setting; }
private void Form1_FormClosi ng(object sender, FormClosingEven tArgs e) { // Save any of my settings Properties.Sett ings.Default.Sa ve(); }
My problem is that textBox1.Text MySetting is not being restored correctly - it always reverts to its "initial" value.
-BT
"Bit Twiddler" <bi***********@ hotmail.com> wrote in message news:%2******** *******@tk2msft ngp13.phx.gbl.. . > Hi, > > I have a windows form app which would benefit from the new application > settings support in VS2005. > > Say that my form has a single textbox on it. When the form closes I > would like to save the text in that textbox as part as the user level > application settings. When the application restarts I would like that > text to be restored to the textbox. > > Because I am not using a built-in property on my form does this mean > that I cannot use the designer to add my setting? > > Or, do I *have* to create a custom class derived from > ApplicationSett ingsBase and manage everything myself? > > No matter how I approach this I cannot seem to get my settings to > "automagica lly" restore their values at app startup. > > Any pointers would be greatly appreciated! > > BT > > >
Thank you Nicholas - for YEARS you have been helping countless thousands of
developers and you are much appreciated.
BT
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:ub******** ******@TK2MSFTN GP10.phx.gbl... BT,
Almost. I think you want:
textBox1.DataBi ndings.Add("Tex t", Properties.Sett ings.Default, "MySetting" );
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard. caspershouse.co m
"Bit Twiddler" <bi***********@ hotmail.com> wrote in message news:%2******** ********@TK2MSF TNGP12.phx.gbl. .. Thank you for the suggestion Nicholas and in fact I was just trying to figure out the correct way to do that.
I am not sure how to create the binding between Properties.Sett ings.Default.My Setting and the Text property of the textBox1 textbox.
textBox1.DataBi ndings.Add("Tex t", Properties.Sett ings, "Default.MySett ing ");
Is this correct?
Thanks! BT
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in message news:uU******** ******@TK2MSFTN GP11.phx.gbl... BT,
Why not use data binding and just bind the value of the textbox to the MySetting property on the object? This would probably be much easier.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard. caspershouse.co m
"Bit Twiddler" <bi***********@ hotmail.com> wrote in message news:%2******** *******@TK2MSFT NGP15.phx.gbl.. . Ok, I figured it out - of course it was user error.
I was not updating the settings when the text of the textbox was actually changed! :(
private void textBox1_TextCh anged(object sender, EventArgs e) { Properties.Sett ings.Default.My Setting = textBox1.Text; } -BT
"Bit Twiddler" <bi***********@ hotmail.com> wrote in message news:O$******** ******@TK2MSFTN GP11.phx.gbl... > Just to provide more information: > > Using the designer I added the following setting (using the designer) > Name: MySetting > Type: string > Scope: User > Value: Initial value > > public Form1() > { > InitializeCompo nent(); > // Load the data from user.config > textBox1.Text = Properties.Sett ings.Default.My Setting; > } > > private void Form1_FormClosi ng(object sender, FormClosingEven tArgs e) > { > // Save any of my settings > Properties.Sett ings.Default.Sa ve(); > } > > My problem is that textBox1.Text MySetting is not being restored > correctly - it always reverts to its "initial" value. > > -BT > > > "Bit Twiddler" <bi***********@ hotmail.com> wrote in message > news:%2******** *******@tk2msft ngp13.phx.gbl.. . >> Hi, >> >> I have a windows form app which would benefit from the new >> application settings support in VS2005. >> >> Say that my form has a single textbox on it. When the form closes I >> would like to save the text in that textbox as part as the user level >> application settings. When the application restarts I would like >> that text to be restored to the textbox. >> >> Because I am not using a built-in property on my form does this mean >> that I cannot use the designer to add my setting? >> >> Or, do I *have* to create a custom class derived from >> ApplicationSett ingsBase and manage everything myself? >> >> No matter how I approach this I cannot seem to get my settings to >> "automagica lly" restore their values at app startup. >> >> Any pointers would be greatly appreciated! >> >> BT >> >> >> > >
BT,
Thanks for the props. Much appreciated.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Bit Twiddler" <bi***********@ hotmail.com> wrote in message
news:uX******** ******@TK2MSFTN GP12.phx.gbl... Thank you Nicholas - for YEARS you have been helping countless thousands of developers and you are much appreciated.
BT
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in message news:ub******** ******@TK2MSFTN GP10.phx.gbl... BT,
Almost. I think you want:
textBox1.DataBi ndings.Add("Tex t", Properties.Sett ings.Default, "MySetting" );
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard. caspershouse.co m
"Bit Twiddler" <bi***********@ hotmail.com> wrote in message news:%2******** ********@TK2MSF TNGP12.phx.gbl. .. Thank you for the suggestion Nicholas and in fact I was just trying to figure out the correct way to do that.
I am not sure how to create the binding between Properties.Sett ings.Default.My Setting and the Text property of the textBox1 textbox.
textBox1.DataBi ndings.Add("Tex t", Properties.Sett ings, "Default.MySett ing ");
Is this correct?
Thanks! BT
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in message news:uU******** ******@TK2MSFTN GP11.phx.gbl... BT,
Why not use data binding and just bind the value of the textbox to the MySetting property on the object? This would probably be much easier.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard. caspershouse.co m
"Bit Twiddler" <bi***********@ hotmail.com> wrote in message news:%2******** *******@TK2MSFT NGP15.phx.gbl.. . > Ok, I figured it out - of course it was user error. > > I was not updating the settings when the text of the textbox was > actually changed! :( > > private void textBox1_TextCh anged(object sender, EventArgs e) > { > Properties.Sett ings.Default.My Setting = textBox1.Text; > } > -BT > > "Bit Twiddler" <bi***********@ hotmail.com> wrote in message > news:O$******** ******@TK2MSFTN GP11.phx.gbl... >> Just to provide more information: >> >> Using the designer I added the following setting (using the designer) >> Name: MySetting >> Type: string >> Scope: User >> Value: Initial value >> >> public Form1() >> { >> InitializeCompo nent(); >> // Load the data from user.config >> textBox1.Text = Properties.Sett ings.Default.My Setting; >> } >> >> private void Form1_FormClosi ng(object sender, FormClosingEven tArgs e) >> { >> // Save any of my settings >> Properties.Sett ings.Default.Sa ve(); >> } >> >> My problem is that textBox1.Text MySetting is not being restored >> correctly - it always reverts to its "initial" value. >> >> -BT >> >> >> "Bit Twiddler" <bi***********@ hotmail.com> wrote in message >> news:%2******** *******@tk2msft ngp13.phx.gbl.. . >>> Hi, >>> >>> I have a windows form app which would benefit from the new >>> application settings support in VS2005. >>> >>> Say that my form has a single textbox on it. When the form closes I >>> would like to save the text in that textbox as part as the user >>> level application settings. When the application restarts I would >>> like that text to be restored to the textbox. >>> >>> Because I am not using a built-in property on my form does this mean >>> that I cannot use the designer to add my setting? >>> >>> Or, do I *have* to create a custom class derived from >>> ApplicationSett ingsBase and manage everything myself? >>> >>> No matter how I approach this I cannot seem to get my settings to >>> "automagica lly" restore their values at app startup. >>> >>> Any pointers would be greatly appreciated! >>> >>> BT >>> >>> >>> >> >> > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: KennethBohman |
last post by:
Hi everybody,
Question: how can I use the executable.config-files during installation? The
answer might seem obvious, but there is apparently more to it!
My itention was, as part of the iinstallation, to write write two settings
to the .config file for the executable. I don't usually do that, but for such
a small application I thought it would be alright.
I created a simple Install class, added an override for the Install
|
by: grs |
last post by:
Can a class library have a app.config file. Reason for asking is that the
microsoft application blocks all read from myApp.exe.config. How can you use
the application blocks if you do not have an app.config file.
Wish someone from microsoft would answer this, I am at a loss.
thanks
grs
|
by: Jim Heavey |
last post by:
Hello, I am trying to figure out how to add <listeners> to the web config.
The book that I am using shows the following:
<system.diagnostics>
<trace>
<listeners>
<add ....... />
</listeners>
</trace>
</system.diagnostics>
|
by: Mark |
last post by:
Our team uses VSS. We each have a user.config file for local settings. One
developer's file does NOT kick in - it pulls directly from the web.config
file.
1. The user.config file is in the same directory as the web.config (root).
2. There is nothing crazy about the contents. The contents are posted
below.
3. The user.config file is in the appropriate directory, but has not been
included in VSS.
|
by: Dean Slindee |
last post by:
I store several application settings in the project's "app.config" file. I
also have a form that reads these values and displays them in a listview so
that the user can adjust them. My question is: can the changes made by the
user to the settings values be saved back to "app.config" so that when the
application is launched tomorrow, the updated values are used?
Since the original app.config settings are loaded to...
| |
by: Ben |
last post by:
I have a group of settings that I'd like to have inherited by multiple
sites.
I'm trying this, but it's not working.
wwwroot\group\web.config
wwwroot\group\site1\web.config
wwwroot\group\site2\web.config
Where site1 & site2 are applications.
|
by: dgk |
last post by:
I've used the Website Administration Tool to create a few roles and
users using the default (SQLExpress?) providers. But when I try to to
access them using the ProfileManager:
lblCnt.Text =
ProfileManager.GetNumberOfProfiles(ProfileAuthenticationOption.All).ToString
I get zero. What I really need to do is add some custom fields to the
user profile, which I've done in web.config and populate that data
when I create a new user. The...
|
by: Matt F |
last post by:
Two of the projects in my solution that both need to use a common
user.config file. This is a data application - the executable that is
created with the first project is the primary executable that users will be
working with 99% of the time, the other is a seperate "maintenance"
executable. The connection string is stored via My.Settings (encrypted of
course). The problem is that obviously with 2 different .exe there are 2
seperate...
|
by: Piotrekk |
last post by:
Hi
I have a problem connected with user.config file. I am using default
settings.settings . To settings.settings I am adding one user scope
string and one application scope string. Thus app.config file is added
to my project. When I build and run the project app.exe.config file is
created and added to application base directory. This file contains
two strings added previously.
Q1: No user.config file is created in my documents and...
|
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...
|
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,...
| |
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...
|
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...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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();...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |