PropertyGrid.PropertySort Propiedad

Definición

Obtiene o establece el tipo de ordenación que utiliza PropertyGrid para mostrar propiedades.

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

Valor de propiedad

Uno de los valores de PropertySort. El valor predeterminado es Categorized o Alphabetical.

Excepciones

El valor asignado no es uno de los valores de PropertySort.

Ejemplos

En el ejemplo de código siguiente se muestra cómo inicializar un PropertyGrid control mediante las PropertySortpropiedades , ToolbarVisible . Además, en este ejemplo se establece la PropertyGrid propiedad del Visible control en false para que la cuadrícula no sea visible cuando se ejecute el ejemplo. Para ejecutar este ejemplo, pegue el código siguiente en un formulario y llame al InitializePropertyGrid método desde el constructor o Load el método de control de eventos del formulario. Para ver la cuadrícula de propiedades cuando se ejecuta el formulario, cambie la propiedad de Visible la cuadrícula a , vuelva a compilar y vuelva a trueejecutar el formulario.

   // 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

Comentarios

Al establecer la PropertySort propiedad, la apariencia de los botones de ordenación de propiedades en la cuadrícula cambia para reflejar el estado actual de la propiedad. Establecer PropertySort en PropertySort.NoSort hace que las propiedades se muestren en el orden en que se recuperaron.

Establecer PropertySort en y AlphabeticalCategorized es el mismo que establecer PropertySort en Categorized solo. La vista clasificada siempre se muestra como alfabética.

Nota

Para realizar la ordenación personalizada, implemente ICustomTypeDescriptor en el componente para devolver las propiedades en el orden deseado.

Se aplica a