I am creating a application that store basic database connection info like host,user, password and default database name in application settings using User Scope.
I am using .net 3.5 with Visual Studio 2008
I put 4 text boxes in a user control and bound their text property to the application settings individual properties.
// // textBox_database // this.textBox_database.Location = new System.Drawing.Point(103, 101); this.textBox_database.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.textBox_database.Name = 'textBox_database'; this.textBox_database.Size = new System.Drawing.Size(255, 27); this.textBox_database.TabIndex = 5; this.textBox_database.Text = global::PHP_Code_Generator_2.Properties.Settings.Default.mysql_database; // // textBox_password // this.textBox_password.Location = new System.Drawing.Point(103, 69); this.textBox_password.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.textBox_password.Name = 'textBox_password'; this.textBox_password.Size = new System.Drawing.Size(255, 27); this.textBox_password.TabIndex = 4; this.textBox_password.Text = global::PHP_Code_Generator_2.Properties.Settings.Default.mysql_password; this.textBox_password.UseSystemPasswordChar = true; // // textBox_user // this.textBox_user.Location = new System.Drawing.Point(103, 37); this.textBox_user.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.textBox_user.Name = 'textBox_user'; this.textBox_user.Size = new System.Drawing.Size(255, 27); this.textBox_user.TabIndex = 7; this.textBox_user.Text = global::PHP_Code_Generator_2.Properties.Settings.Default.mysql_user; // // textBox_server // this.textBox_server.Location = new System.Drawing.Point(103, 5); this.textBox_server.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.textBox_server.Name = 'textBox_server'; this.textBox_server.Size = new System.Drawing.Size(255, 27); this.textBox_server.TabIndex = 6; this.textBox_server.Text = global::PHP_Code_Generator_2.Properties.Settings.Default.mysql_server;
these text boxes will get user data from users to set their own database info. i have a button that saves the modified info back to the settings file
private void button_save_Click(object sender, EventArgs e) { Properties.Settings.Default.Save(); }
but the design is not being saved. any help anyone?
regards, Anjan
To Cyril: Yes i had the code to assign modified value in properties, but then even the scope was set to ‘User’ it said readonly. So i removed the property assignment codes. now i brought the code back and restarted VS, it works perfect now 😀 silly me, i should have try this old procedure before. Thank you Cyril.
Hmm… I remember having the same problem a few months ago in one of my projects. Unfortunately I don’t recall how I solved it.
Some checks…