Adds the specified TableSetting to the collection.
[Visual Basic] Overloads Public Sub Add( _ ByVal tableSetting As TableSetting _ ) [C#] public void Add( TableSetting tableSetting ); [C++] public: void Add( TableSetting* tableSetting ); [JScript] public function Add( tableSetting : TableSetting );
Exception Type | Condition |
---|---|
ArgumentNullException | The tableSetting parameter is a null reference (in Visual Basic Nothing). |
ArgumentException | The tableSetting already belongs to this collection, or another collection. |
DuplicateNameException | The collection already has a TableSetting with the same name (not case-sensitive). |
InvalidExpressionException | The TableSetting has a compute expression and it can't be bound. |
The OnCollectionChanged event occurs if the method succeeds.
The following example creates a DataSetView and adds two TableSetting objects to the TableSettingsCollection.
' 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 = New TableSetting(myDataSet.Tables("Suppliers"), "CompanyName", _ "CompanyName < Z" & Combo1.Text, DataRowState.ModifiedCurrent) myDataSetView.TableSettings.Add(ts) ' Create and add second TableSetting. ts = New TableSetting(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 | DataSetView | TableSetting