PropertyGrid クラス
オブジェクトのプロパティを参照するためのユーザー インターフェイスを提供します。
この型のすべてのメンバの一覧については、PropertyGrid メンバ を参照してください。
System.Object
System.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.Control
System.Windows.Forms.ScrollableControl
System.Windows.Forms.ContainerControl
System.Windows.Forms.PropertyGrid
Public Class PropertyGrid
Inherits ContainerControl
[C#]
public class PropertyGrid : ContainerControl
[C++]
public __gc class PropertyGrid : public ContainerControl
[JScript]
public class PropertyGrid extends ContainerControl
スレッドセーフ
この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。
解説
プロパティ グリッドを使用するには、親コントロール上で PropertyGrid クラスの新しいインスタンスを作成し、プロパティを表示する対象のオブジェクトを SelectedObject に設定します。
グリッドに表示される情報は、オブジェクトが割り当てられた時点におけるプロパティのスナップショットです。 SelectedObject で指定されたオブジェクトのプロパティ値が実行時にコードによって変更されても、グリッドを更新するためのアクションが実行されるまでは、新しい値は表示されません。
プロパティ グリッド内のプロパティ タブは PropertyGrid の上部のツール バーのボタンとして表示され、 PropertyTabScope 列挙体に定義されているスコープで変化します。
開発環境のツールボックスには、初期状態では PropertyGrid コントロールは表示されません。必要に応じてツールボックスにプロパティ グリッドを追加できます。追加すると、 PropertyGrid オブジェクトをフォームにドラッグ アンド ドロップできるようになります。適切なコードをソース コードに追加して、 PropertyGrid のインスタンスを定義することもできます。
使用例
[Visual Basic, C#, C++] プロパティ グリッドを作成し、そのグリッドのフォーム上の位置を設定する例を次に示します。この例は、フォーム上に TextBox が配置されていることを前提にしています。
Public Sub New()
' The initial constructor code goes here.
Dim propertyGrid1 As New PropertyGrid()
propertyGrid1.CommandsVisibleIfAvailable = True
propertyGrid1.Location = New Point(10, 20)
propertyGrid1.Size = New System.Drawing.Size(400, 300)
propertyGrid1.TabIndex = 1
propertyGrid1.Text = "Property Grid"
Me.Controls.Add(propertyGrid1)
propertyGrid1.SelectedObject = textBox1
End Sub
[C#]
public Form1() {
// The initial constructor code goes here.
PropertyGrid propertyGrid1 = new PropertyGrid();
propertyGrid1.CommandsVisibleIfAvailable = true;
propertyGrid1.Location = new Point(10, 20);
propertyGrid1.Size = new System.Drawing.Size(400, 300);
propertyGrid1.TabIndex = 1;
propertyGrid1.Text = "Property Grid";
this.Controls.Add(propertyGrid1);
propertyGrid1.SelectedObject = textBox1;
}
[C++]
public:
Form1() {
// The initial constructor code goes here.
PropertyGrid* propertyGrid1 = new PropertyGrid();
propertyGrid1->CommandsVisibleIfAvailable = true;
propertyGrid1->Location = Point(10, 20);
propertyGrid1->Size = System::Drawing::Size(400, 300);
propertyGrid1->TabIndex = 1;
propertyGrid1->Text = S"Property Grid";
this->Controls->Add(propertyGrid1);
propertyGrid1->SelectedObject = textBox1;
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
名前空間: System.Windows.Forms
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
アセンブリ: System.Windows.Forms (System.Windows.Forms.dll 内)
参照
PropertyGrid メンバ | System.Windows.Forms 名前空間 | PropertyTabScope