PropertyGrid.PropertySort Eigenschaft

Definition

Ruft den Sortiertyp ab, den PropertyGrid für die Anzeige von Eigenschaften verwendet, oder legt diesen fest.

public:
 property System::Windows::Forms::PropertySort PropertySort { System::Windows::Forms::PropertySort get(); void set(System::Windows::Forms::PropertySort value); };
public System.Windows.Forms.PropertySort PropertySort { get; set; }
member this.PropertySort : System.Windows.Forms.PropertySort with get, set
Public Property PropertySort As PropertySort

Eigenschaftswert

Einer der PropertySort-Werte. Der Standardwert ist Categorized oder Alphabetical.

Ausnahmen

Der zugewiesene Wert ist keiner der PropertySort-Werte.

Beispiele

Im folgenden Codebeispiel wird die Initialisierung eines PropertyGrid Steuerelements mithilfe der PropertySortEigenschaften , ToolbarVisible veranschaulicht. Darüber hinaus wird in diesem Beispiel die PropertyGrid -Eigenschaft des Steuerelements Visible auf false festgelegt, sodass das Raster nicht sichtbar ist, wenn das Beispiel ausgeführt wird. Fügen Sie zum Ausführen dieses Beispiels den folgenden Code in ein Formular ein, und rufen Sie die InitializePropertyGrid -Methode aus dem Konstruktor oder Load der Ereignisbehandlungsmethode des Formulars auf. Um das Eigenschaftenraster anzuzeigen, wenn das Formular ausgeführt wird, ändern Sie die Eigenschaft des Rasters Visible in true, kompilieren sie erneut, und führen Sie das Formular erneut aus.

   // Declare a propertyGrid.
internal:
   PropertyGrid^ propertyGrid1;

private:

   // Initialize propertyGrid1.
   [PermissionSetAttribute(SecurityAction::Demand, Name="FullTrust")]
   void InitializePropertyGrid()
   {
      propertyGrid1 = gcnew PropertyGrid;
      propertyGrid1->Name = "PropertyGrid1";
      propertyGrid1->Location = System::Drawing::Point( 185, 20 );
      propertyGrid1->Size = 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 );
   }

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

'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

Hinweise

Wenn Sie die PropertySort -Eigenschaft festlegen, ändert sich die Darstellung der Eigenschaftensortierschaltflächen im Raster, um den aktuellen Zustand der Eigenschaft widerzuspiegeln. Wenn Sie auf PropertySort.NoSort festlegenPropertySort, werden die Eigenschaften in der Reihenfolge angezeigt, in der sie abgerufen wurden.

Die Einstellung PropertySort auf Alphabetical und Categorized ist identisch mit der Einstellung PropertySort auf Categorized allein. Die kategorisierte Ansicht wird immer als alphabetisch angezeigt.

Hinweis

Um eine benutzerdefinierte Sortierung durchzuführen, implementieren Sie ICustomTypeDescriptor für die Komponente, um die Eigenschaften in der gewünschten Reihenfolge zurückzugeben.

Gilt für: