共用方式為


DataTable.DefaultView 屬性

定義

取得可能含有已篩選檢視表或游標位置的資料表自訂檢視表。

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

屬性值

DataView 關聯的 DataTable

屬性

範例

下列範例會透過 DefaultView 屬性設定 物件的 DataView 屬性DataTable。 此範例也會示範控件系 DataGridView 結至 DataTable 名為 「Suppliers」 的控件,其中包含名為 「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

備註

屬性會 DefaultViewDataView 回可用來排序、篩選和搜尋 的 DataTable

適用於

另請參閱