Windows.Forms.PropertyGrid



データをセットする

this.PropertyGrid.SelectedObject = データの入っているクラスのインスタンス

デフォルト値

[DefaultValue(false)]
public bool Foo { get; set; }

表示しない

[Browsable(false)]
public bool Foo { get; set; }

説明表示

[Description("ここに説明を書く")]
public bool Foo { get; set; }

グループ

FooとBarは同じグループとして表示される
[Category("友達")]
public bool Foo { get; set; }

[Category("友達")]
public bool Bar { get; set; }

書き込めなくする

[ReadOnly(true)]
public bool Foo { get; set; }

デフォルトプロパティ

Barにフォーカスがある状態で開始する
[DefaultProperty("Bar")]
public class Settings
{
 public bool Foo { get; set; }
 public bool Bar { get; set; }
}

内包クラスを展開できるようにする

[TypeConverter(typeof(ExpandableObjectConverter))]
public class Foo { get; set; }

ファイルを開く

参照設定にSystem.Designを追加が必要
using System.Drawing.Design;
using System.Windows.Forms.Design;
[Editor(typeof(FileNameEditor), typeof(UITypeEditor))]
public string Foo { get; set; }
最終更新:2013年03月15日 08:56