DataView 建構函式
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
初始化 DataView 類別的新執行個體。
多載
DataView() |
初始化 DataView 類別的新執行個體。 |
DataView(DataTable) | |
DataView(DataTable, String, String, DataViewRowState) |
使用指定的 DataTable、RowFilter、Sort 和 DataViewRowState,初始化 DataView 類別的新執行個體。 |
DataView()
- 來源:
- DataView.cs
- 來源:
- DataView.cs
- 來源:
- DataView.cs
初始化 DataView 類別的新執行個體。
public:
DataView();
public DataView ();
Public Sub New ()
範例
下列範例會建立新的 DataView。
private void MakeDataView()
{
DataView view = new DataView();
view.Table = DataSet1.Tables["Suppliers"];
view.AllowDelete = true;
view.AllowEdit = true;
view.AllowNew = true;
view.RowFilter = "City = 'Berlin'";
view.RowStateFilter = DataViewRowState.ModifiedCurrent;
view.Sort = "CompanyName DESC";
// Simple-bind to a TextBox control
Text1.DataBindings.Add("Text", view, "CompanyName");
}
Private Sub MakeDataView()
Dim view As New DataView()
view.Table = DataSet1.Tables("Suppliers")
view.AllowDelete = True
view.AllowEdit = True
view.AllowNew = True
view.RowFilter = "City = 'Berlin'"
view.RowStateFilter = DataViewRowState.ModifiedCurrent
view.Sort = "CompanyName DESC"
' Simple-bind to a TextBox control
Text1.DataBindings.Add("Text", view, "CompanyName")
End Sub
另請參閱
適用於
DataView(DataTable)
- 來源:
- DataView.cs
- 來源:
- DataView.cs
- 來源:
- DataView.cs
public:
DataView(System::Data::DataTable ^ table);
public DataView (System.Data.DataTable? table);
public DataView (System.Data.DataTable table);
new System.Data.DataView : System.Data.DataTable -> System.Data.DataView
Public Sub New (table As DataTable)
參數
範例
下列範例會使用指定的 DataTable建立新的 DataView 。
private void MakeDataView()
{
DataView view = new DataView(DataSet1.Tables["Suppliers"]);
// Bind a ComboBox control to the DataView.
Combo1.DataSource = view;
Combo1.DisplayMember = "Suppliers.CompanyName";
}
Private Sub MakeDataView()
Dim view As DataView
view = New DataView(DataSet1.Tables("Suppliers"))
' Bind a ComboBox control to the DataView.
Combo1.DataSource = view
Combo1.DisplayMember = "Suppliers.CompanyName"
End Sub
另請參閱
適用於
DataView(DataTable, String, String, DataViewRowState)
- 來源:
- DataView.cs
- 來源:
- DataView.cs
- 來源:
- DataView.cs
使用指定的 DataTable、RowFilter、Sort 和 DataViewRowState,初始化 DataView 類別的新執行個體。
public:
DataView(System::Data::DataTable ^ table, System::String ^ RowFilter, System::String ^ Sort, System::Data::DataViewRowState RowState);
public DataView (System.Data.DataTable table, string? RowFilter, string? Sort, System.Data.DataViewRowState RowState);
public DataView (System.Data.DataTable table, string RowFilter, string Sort, System.Data.DataViewRowState RowState);
new System.Data.DataView : System.Data.DataTable * string * string * System.Data.DataViewRowState -> System.Data.DataView
Public Sub New (table As DataTable, RowFilter As String, Sort As String, RowState As DataViewRowState)
參數
- RowState
- DataViewRowState
要套用至 DataView 的 DataViewRowState。
範例
下列範例會使用指定的 DataTable建立新的 DataView 。
private void MakeDataView(DataSet dataSet)
{
DataView view = new DataView(dataSet.Tables["Suppliers"],
"Country = 'UK'", "CompanyName",
DataViewRowState.CurrentRows);
view.AllowEdit = true;
view.AllowNew = true;
view.AllowDelete = true;
}
Private Sub MakeDataView(ByVal dataSet As DataSet)
Dim view As New DataView(dataSet.Tables("Suppliers"), _
"Country = 'UK'", "CompanyName", _
DataViewRowState.CurrentRows)
view.AllowEdit = True
view.AllowNew = True
view.AllowDelete = True
End Sub