Gets or sets all the columns of the columns collection.
[Visual Basic] Overridable Public Property All As DataColumn () [C#] public DataColumn[] All {virtual get; virtual set;} [C++] public: __property virtual DataColumn* get_All(); public: __property virtual void set_All(DataColumn*[]); [JScript] public function get All() : DataColumn[]; public function set All(DataColumn[]);
An array of DataColumn objects.
Exception Type | Condition |
---|---|
ArgumentException | A column that is added shouldn't be added and/or a column that is removed shouldn't be removed. |
If an exception is thrown, the collection returns to its original state.If the collection is succesfully changed by adding or removing columns, the OnCollectionChanged event occurs.
The following examples show how to set and get arrays of columns using the All method.
[Visual Basic]
Private Sub GetAllCols() Dim cols As ColumnsCollection ' Get the ColumnsCollection from a DataTable in a DataSet. cols = DataSet1.Tables("Orders").Columns ' Create the array and populate it with the All property. Dim arrCols() As DataColumn arrCols = cols.All Dim i As Integer For i = 0 To UBound(arrCols) - 1 Console.WriteLine(arrCols(i).ColumnName) Next End Sub Private SetAllCols() Dim colArray(1) As DataColumn Dim cols As New ColumnsCollection Dim myCol As DataColumn myCol = New DataColumn myCol.DataType = Type.GetTpe("System.Int16") myCol.ColumnName = "Column 1" colArray(0) = myCol myCol = New DataColumn myCol.DataType = Type.GetTpe("System.String") myCol.ColumnName = "Column 2" colArray(1) = myCol cols.All = colArray End Sub
ColumnsCollection Class | ColumnsCollection Members | System.Data Namespace | Add | Clear | Remove