System.Data Namespace DataColumnCollection Class
Initializes and adds a new DataColumn to the columns collection.
[ VB ] Overloads Public Function Add ( ) As DataColumn [ C# ] public virtual DataColumn Add ( ); [ C++ ] public: virtual DataColumn* Add ( ); [ JScript ] public function Add ( ) : DataColumn;
The newly created DataColumn.
A default name ( "Column1", "Column2", etc. ) is given to the column.
If the collection is successfully changed by adding or removing columns, the CollectionChanged event occurs.
The following example initializes and adds a new DataColumn to the DataColumnCollection of a DataTable using this constructor.
Private Sub AddColumn ( ) ' get the DataColumnCollection from a table in a DataSet. Dim cols As DataColumnCollection = ds.Tables ( "Prices" ).Columns Dim myCol As DataColumn = cols.Add ( ) With myCol .ColumnName = "Total" .DataType = System.Type.GetType ( "System.Decimal" ) .Expression = "UnitPrice * Quantity" .ReadOnly = True .Unique = False End With End Sub
DataColumnCollection Members DataColumnCollection.Add Overload List
© 2000-2010 Rey Nuñez All rights reserved.If you have any question, comment or suggestion about this site, please send us a note
You can help support asp.net.ph