Updating winform settings

I'm trying to update my user settings in a winform and see the results in a label (purely for testing). However, the values aren't changing. Have I forgot to do something?

At the moment I am getting the initial values with the following code:

PortLable.Text = Settings.Default.Port;
IPLable.Text = Settings.Default.ServerAddress;

These two lines are held in the initializer of my first winform. These labels show the default values I set them to in the properites window. Then in my settings form I am trying to update the default values with user values with the following lines of code:

private void ServerConnection_FormClosed(object sender, FormClosedEventArgs e)
  Settings.Default.Port = PortBox.Text;
  Settings.Default.ServerAddress = AddressBox.Text;

However, when I enter the values and close the second form, the values in my first form don't update to show these new values. Have I forgot to do something?


PortLable.Text = Settings.Default.Port;

You are doing it wrong. Select the label in the designer and use (ApplicationSettings) at the top of the Properties window to bind the Text property to a setting. Now it will always show the setting value, you no longer need this statement anymore either.

The labels on your first form do not get updated. You change the variables in the Settings.Default object, but they are not passed on to PortLable.Text and IPLable.Text, because their is no reference between them.

Try updating them when the first form is back in control.

Need Your Help

Load image from listview to next Activity

android android-listview

I am using Listview to display image and data using json parser,

Position control and label horizontally


I am asking myself why this is showing the TextBox and the Label horizontally:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.