PropertyGrid.PropertySort プロパティ

定義

重要

一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。

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

public System.Windows.Forms.PropertySort PropertySort { get; set; }

プロパティ値

PropertySort 値のいずれか 1 つ。 既定値は Categorized または Alphabetical です。

例外

代入された値が、PropertySort 値ではありません。

次のコード例では、 プロパティを使用してコントロールをPropertyGrid初期化する方法をPropertySortToolbarVisible示します。 さらに、この例では、コントロールの Visible プロパティを にfalse設定PropertyGridして、この例の実行時にグリッドが表示されないようにします。 この例を実行するには、次のコードをフォームに貼り付け、フォームのコンストラクターまたはLoadイベント処理メソッドから メソッドを呼び出InitializePropertyGridします。 フォームの実行中にプロパティ グリッドを表示するには、グリッドの Visible プロパティを に変更し true、再コンパイルして、フォームを再実行します。


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

注釈

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

Categorized の両方Alphabeticalに設定PropertySortすることは、 を単独でに設定したCategorized場合PropertySortと同じです。 分類されたビューは常にアルファベット順で表示されます。

注意

カスタム並べ替えを行うには、 を コンポーネントに実装 ICustomTypeDescriptor して、目的の順序でプロパティを返します。

適用対象

製品 バージョン
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9