DataTable.DefaultView 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 une vue personnalisée de la table qui peut inclure une vue filtrée ou une position de curseur.
public:
property System::Data::DataView ^ DefaultView { System::Data::DataView ^ get(); };
[System.ComponentModel.Browsable(false)]
public System.Data.DataView DefaultView { get; }
[System.ComponentModel.Browsable(false)]
[System.Data.DataSysDescription("DataTableDefaultViewDescr")]
public System.Data.DataView DefaultView { get; }
[<System.ComponentModel.Browsable(false)>]
member this.DefaultView : System.Data.DataView
[<System.ComponentModel.Browsable(false)>]
[<System.Data.DataSysDescription("DataTableDefaultViewDescr")>]
member this.DefaultView : System.Data.DataView
Public ReadOnly Property DefaultView As DataView
Valeur de propriété
Associé DataView au DataTable.
- Attributs
Exemples
L’exemple suivant définit une propriété de l’objet DataTableDataView via la DefaultView propriété. L’exemple montre également la liaison d’un DataGridView contrôle à un DataTable « Suppliers » nommé « Suppliers » qui inclut une colonne nommée « CompanyName ».
private void BindDataGrid()
{
DataTable table = new DataTable();
// Insert code to populate a DataTable with data.
// Bind grid to DataTable.
dataGrid1.DataSource = table;
}
private void ChangeRowFilter()
{
DataTable gridTable = (DataTable) dataGrid1.DataSource;
// Set the RowFilter to display a company names that
// begin with A through I..
gridTable.DefaultView.RowFilter = "CompanyName < 'I'";
}
Private Sub BindDataGrid()
Dim table As New DataTable
' Insert code to populate a DataTable with data.
' Bind DataGrid to DataTable
DataGrid1.DataSource = table
End Sub
Private Sub ChangeRowFilter()
Dim gridTable As DataTable = _
CType(dataGrid1.DataSource, DataTable)
' Set the RowFilter to display a company names
' that begin with A through I.
gridTable.DefaultView.RowFilter = "CompanyName < 'I'"
End Sub
Remarques
La DefaultView propriété retourne un DataView élément que vous pouvez utiliser pour trier, filtrer et rechercher un DataTable.