DataGrid.AllowSorting Propriété

Définition

Obtient ou définit une valeur indiquant si la grille peut être triée à nouveau en cliquant sur un en-tête de colonne.

public:
 property bool AllowSorting { bool get(); void set(bool value); };
public bool AllowSorting { get; set; }
member this.AllowSorting : bool with get, set
Public Property AllowSorting As Boolean

Valeur de propriété

Boolean

true si les colonnes peuvent être triées ; sinon, false.

Exemples

L’exemple de code suivant bascule la AllowSorting propriété.

private:
   void ToggleAllowSorting()
   {
      // Toggle the AllowSorting property.
      dataGrid1->AllowSorting =  !dataGrid1->AllowSorting;
   }
private void ToggleAllowSorting()
{
   // Toggle the AllowSorting property.
   dataGrid1.AllowSorting = ! dataGrid1.AllowSorting;
}
Private Sub ToggleAllowSorting()

   ' Toggle the AllowSorting property.
   DataGrid1.AllowSorting = Not DataGrid1.AllowSorting
End Sub

Remarques

Cette propriété est remplacée par la DataGridTableStyle.AllowSorting propriété s’il existe actuellement un DataGridTableStyle effet pour le contrôle.

Si le tri est autorisé, le fait de cliquer sur un en-tête de colonne trie les données de la table par cette colonne.

Vous pouvez également trier à l’aide d’une expression pour un DataColumn. Pour Expression plus d’informations sur la création d’une expression de tri.

Si le System.Windows.Forms.DataGrid paramètre est lié à un DataView, vous pouvez définir un tri personnalisé pour la table à l’aide de la propriété de Sort la DataView classe. De même, si la System.Windows.Forms.DataGrid table est liée à un DataViewManager, chaque table dans la DataViewManager zone peut avoir un tri personnalisé en définissant la propriété de Sort la DataViewSettings classe.

S’applique à

Voir aussi