1

ユーザースコープを使用して、ホスト、ユーザー、パスワード、デフォルトのデータベース名などの基本的なデータベース接続情報をアプリケーション設定に保存するアプリケーションを作成しています。

VisualStudio2008で.net3.5を使用しています

ユーザーコントロールに4つのテキストボックスを配置し、それらのテキストプロパティをアプリケーション設定の個々のプロパティにバインドしました。

// 
        // 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;

これらのテキストボックスは、ユーザーからユーザーデータを取得して、独自のデータベース情報を設定します。変更した情報を設定ファイルに保存するボタンがあります

private void button_save_Click(object sender, EventArgs e)
{
   Properties.Settings.Default.Save();
}

しかし、デザインは保存されていません。誰か助けてくれませんか?

よろしく、アンジャン

Cyrilへ:はい、プロパティに変更された値を割り当てるコードがありましたが、スコープが「ユーザー」に設定されていても、読み取り専用と表示されていました。そこで、プロパティ割り当てコードを削除しました。今、私はコードを戻し、VSを再起動しました、それは今完璧に動作します:Dばかげています、私は前にこの古い手順を試すべきでした。シリルありがとう。

4

1 に答える 1

2

うーん... 数か月前に私のプロジェクトの 1 つで同じ問題が発生したことを覚えています。残念ながら、私はそれをどのように解決したか覚えていません。

いくつかのチェック...

  1. プロジェクト プロパティでプロパティ スコープをユーザーに設定してみてください。
  2. あなたがリストしたコードでは、プロパティを設定した場所がわかりません(プロパティを取得しているだけです)。どこに設定しましたか?
于 2009-04-04T05:49:17.297 に答える