次の方法で共有


PropertyGrid.PropertySort プロパティ

プロパティを表示するために PropertyGrid が使用する並べ替えの種類を取得または設定します。

Public Property PropertySort As PropertySort
[C#]
public PropertySort PropertySort {get; set;}
[C++]
public: __property PropertySort get_PropertySort();public: __property void set_PropertySort(PropertySort);
[JScript]
public function get PropertySort() : PropertySort;public function set PropertySort(PropertySort);

プロパティ値

PropertySort 値の 1 つ。既定値は PropertySort.Categorized または PropertySort.Alphabetical です。

解説

PropertySort プロパティを設定すると、グリッド上のプロパティの並べ替えボタンの外観が変わり、プロパティの現在の状態が反映されます。 PropertySortPropertySort.NoSort に設定すると、プロパティは取得された順序で表示されます。

PropertySort を System.Windows.Forms.PropertySort]|Alphabetical に設定することは、 PropertySortPropertySort.Categorized だけに設定することと同じです。カテゴリで分類されたビューは、必ずアルファベット順で表示されます。

使用例

[Visual Basic, C#] PropertySort プロパティおよび System.Windows.Forms.PropertyGrid.ToolBarVisible プロパティを使用して PropertyGrid コントロールを初期化するコード例を次に示します。また、この例では、 System.Windows.Forms.PropertyGrid.Visible プロパティを false に設定して、例を実行したときにグリッドが表示されないようにしています。この例を実行するには、次のコードをフォームに貼り付けて、フォームのコンストラクタまたは Load メソッドで InitializePropertyGrid メソッドを呼び出します。フォーム実行時にプロパティのグリッドを表示するには、グリッドの Visible プロパティを true に変更し、フォームを再度コンパイルして実行します。

 

    'Declare a propertyGrid.
    Friend WithEvents propertyGrid1 As PropertyGrid

    'Initialize propertyGrid1.
    Private Sub InitializePropertyGrid()
        propertyGrid1 = New PropertyGrid
        propertyGrid1.Name = "PropertyGrid1"
        propertyGrid1.Location = New Point(185, 20)
        propertyGrid1.Size = New System.Drawing.Size(150, 300)
        propertyGrid1.TabIndex = 5

        'Set the sort to alphabetical and set Toolbar visible
        'to false, so the user cannot change the sort.
        propertyGrid1.PropertySort = PropertySort.Alphabetical
        propertyGrid1.ToolbarVisible = False
        propertyGrid1.Text = "Property Grid"

        ' Add the PropertyGrid to the form, but set its
        ' visibility to False so it will not appear when the form loads.
        propertyGrid1.Visible = False
        Me.Controls.Add(propertyGrid1)

    End Sub

[C#] 

    // Declare a propertyGrid.
    internal PropertyGrid propertyGrid1;

    // Initialize propertyGrid1.
    private void InitializePropertyGrid()
    {
        propertyGrid1 = new PropertyGrid();
        propertyGrid1.Name = "PropertyGrid1";
        propertyGrid1.Location = new System.Drawing.Point(185, 20);
        propertyGrid1.Size = new System.Drawing.Size(150, 300);
        propertyGrid1.TabIndex = 5;

        // Set the sort to alphabetical and set Toolbar visible
        // to false, so the user cannot change the sort.
        propertyGrid1.PropertySort = PropertySort.Alphabetical;
        propertyGrid1.ToolbarVisible = false;
        propertyGrid1.Text = "Property Grid";

        // Add the PropertyGrid to the form, but set its
        // visibility to False so it will not appear when the form loads.
        propertyGrid1.Visible = false;
        this.Controls.Add(propertyGrid1);

    }

[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

PropertyGrid クラス | PropertyGrid メンバ | System.Windows.Forms 名前空間