0

プロジェクトで使用するパスがたくさんあります。Appication Settings を使用する場合、 Settings オブジェクトをPropertyGridにコードで提供できます: PropertyGrid1.SelectedObject = My.Settings()

オブジェクトを提供できることを読みました(この場合、My.Settingsこのメタ情報ではなくカスタムオブジェクトです:

<Editor(GetType(System.Windows.Forms.Design.FileNameEditor), _
        GetType(System.Drawing.Design.UITypeEditor))>

を使用するときに、ファイル ブラウザを開くエディタを適用するためPropertyGrid。それは素晴らしく、うまくいきます。

アプリケーション設定で使用する VS2010 UI 内でそのようなことを行う可能性はありますか?

System.Windows.Forms.Design.FileNameEditorつまり、プロパティのタイプを に設定すると、エディターではなくタイプが設定されることに気付きました。これは簡単なことです。System.Windows.Forms.Design.FileNameEditorまた、そのプロパティのプロバイダーとして設定しようとしましたが、うまくいきませんでした。

ファイルを開き、Settings.Designer.vb次の行を手動で追加しました。

<Editor(GetType(System.Windows.Forms.Design.FileNameEditor), _
        GetType(System.Drawing.Design.UITypeEditor))>

ファイルピッカーを表示して動作させたいプロパティに。問題は、ファイルが自動生成され、編集できないことです。

Visual Studio 2010 で適切な手順を使用して、その動作を繰り返すにはどうすればよいですか?

4

1 に答える 1

1

Just read the application settings into your own class and assign that class to the propertygrid. I took this edited somewhat from one of my projects:

Call MyFilenameClass
 <Editor(GetType(System.Windows.Forms.Design.FileNameEditor), GetType(System.Drawing.Design.UITypeEditor)), _
  Browsable(True), _
  DefaultValue(""), _
  Category("File"), DisplayName("Filename"), Description("Select the file.")> _
  Public Property MyFileName As String = My.Settings.MyFilename
End Class

So, when the class is created, MyFilename will have the value of My.Settings.MyFilename. In your Form_Closing you will need to put your value back into the Application setting and save it:

My.Settings.MyFilename = "class name in here".MyFilename
My.Settings.Save
于 2012-09-13T12:29:48.353 に答える