Creates and adds a TableSetting with the specified name, sort, filter, and row state filter to the collection.
[Visual Basic] Overloads Public Function Add( _ ByVal table As DataTable, _ ByVal sort As String, _ ByVal rowFilter As String, _ ByVal rowStateFilter As DataViewRowState _ ) As TableSetting [C#] public TableSetting Add( DataTable table, string sort, string rowFilter, DataViewRowState rowStateFilter ); [C++] public: TableSetting* Add( DataTable* table, String* sort, String* rowFilter, DataViewRowState rowStateFilter ); [JScript] public function Add( table : DataTable, sort : String, rowFilter : String, rowStateFilter : DataViewRowState ) : TableSetting;
The newly created TableSetting.
Exception Type | Condition |
---|---|
ArgumentException | The collection already has a tableSetting for this table. |
If a null or empty string is passed in for the name, a default name is given.
The CollectionChanged event occurs if the method succeeds.
The following example creates a DataSetView and adds two TableSetting objects to the TableSettingsCollection.
[Visual Basic]
' The next two lines go into the Declarations section of the module: ' The next two lines go into the Declarations section of the module: Private myDataSetView As DataSetView ' SuppliersProducts is a class derived from DataSet. Private myDataSet As SuppliersProducts Private Sub CreateDataSetView() ' Not shown: SuppliersProducts is already configured with tables, relations, constraints. myDataSet = New SuppliersProducts myDataSetView = New DataSetView(myDataSet) End Sub Private Sub AddTableSettings() ' Create TableSetting and add it to TableSettingsCollection. Dim ts As TableSetting ts = MyDataSetView.TableSettings.Add(myDataSet.Tables("Suppliers"), _ "CompanyName", "CompanyName < Z" & Combo1.Text, DataRowState.ModifiedCurrent) myDataSetView.TableSettings.Add(ts) ' Create and add second TableSetting. ts = MyDataSetView.TableSettings.Add(myDataSet.Tables("Products"), _ "ProductName", "Discontinued = 'True'", DataRowState.CurrentRows) myDataSetView.TableSettings.Add(ts) End Sub
TableSettingsCollection Class | TableSettingsCollection Members | System.Data Namespace | TableSettingsCollection.Add Overload List | DataTable | DataSetView | Expression | DataViewRowState