Bagikan melalui


DataTable.DefaultView Properti

Definisi

Mendapatkan tampilan tabel yang dikustomisasi yang mungkin menyertakan tampilan yang difilter, atau posisi kursor.

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

Nilai Properti

yang DataView terkait dengan DataTable.

Atribut

Contoh

Contoh berikut mengatur properti DataTable objek DataView melalui DefaultView properti . Contohnya juga menunjukkan pengikatan DataGridView kontrol ke DataTable "Pemasok" bernama yang menyertakan kolom bernama "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

Keterangan

Properti DefaultView mengembalikan yang DataView bisa Anda gunakan untuk mengurutkan, memfilter, dan mencari DataTable.

Berlaku untuk

Lihat juga