NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

TableSettingsCollection.Add (DataTable, String, String, DataViewRowState)

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;

Parameters

table
The DataTable to create the TableSetting with.
sort
The sort expression consisting of a column name and optional sort direction. See Remarks for details.
rowFilter
A filter expression. See the Expression property of the DataColumn for details on forming a valid expression.
rowStateFilter
One of the DataViewRowState values.

Return Value

The newly created TableSetting.

Exceptions

Exception Type Condition
ArgumentException The collection already has a tableSetting for this table.

Remarks

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.

Example [Visual Basic]

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

See Also

TableSettingsCollection Class | TableSettingsCollection Members | System.Data Namespace | TableSettingsCollection.Add Overload List | DataTable | DataSetView | Expression | DataViewRowState