PropertyGrid.PropertySort Propriété
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Obtient ou définit le type de tri PropertyGrid des utilisations pour afficher les propriétés.
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
Valeur de propriété
Une des PropertySort valeurs. La valeur par défaut est Categorized ou Alphabetical.
Exceptions
La valeur affectée n’est pas l’une des PropertySort valeurs.
Exemples
L’exemple de code suivant illustre l’initialisation d’un PropertyGrid contrôle à l’aide des PropertySortpropriétés . ToolbarVisible En outre, cet exemple définit la PropertyGrid propriété du Visible contrôle pour false que la grille ne soit pas visible lors de l’exécution de l’exemple. Pour exécuter cet exemple, collez le code suivant dans un formulaire et appelez la InitializePropertyGrid méthode à partir du constructeur ou Load de la méthode de gestion des événements du formulaire. Pour afficher la grille de propriétés lorsque le formulaire est en cours d’exécution, remplacez la propriété truede Visible la grille par , recompilez et réexécutez le formulaire.
// 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
Remarques
Lorsque vous définissez la PropertySort propriété, l’apparence des boutons de tri de propriété sur la grille change pour refléter l’état actuel de la propriété. Le paramètre PropertySort pour PropertySort.NoSort provoquer l’affichage des propriétés dans l’ordre dans lequel elles ont été récupérées.
La définition PropertySort à la fois Alphabetical et Categorized est la même que CategorizedPropertySort la définition seule. L’affichage classé est toujours affiché par ordre alphabétique.
Note
Pour effectuer un tri personnalisé, implémentez ICustomTypeDescriptor sur le composant pour retourner les propriétés dans l’ordre souhaité.