System.Data Namespace DataColumn Class
Sets or retrieves a value indicating whether the column allows changes once a row has been added to the table.
Script |
DataGridColumn.ReadOnly = [ true | false ] |
true if the column is read only; otherwise, false. The default is false.
Exception Type |
Condition |
ArgumentException |
Occurs when the property is set to false on a computed column. |
The following example initializes a DataColumn and sets its ReadOnly property true.
private void AddColumn ( DataTable myTable ) {
// add a DataColumn to the collection and set its properties.
DataColumn myColumn;
// the constructor sets the ColumnName of the column.
myColumn = myTable.Columns.Add ( "Total" );
myColumn.DataType = System.Type.GetType ( "System.Decimal" );
myColumn.ReadOnly = true;
myColumn.Expression = "UnitPrice * Quantity";
myColumn.Unique = false;
}
Private Sub AddColumn ( ByVal myTable As DataTable )
' add a DataColumn to the collection and set its properties.
Dim myColumn As DataColumn
' the constructor sets the ColumnName of the column.
myColumn = myTable.Columns.Add ( "Total" )
myColumn.DataType = System.Type.GetType ( "System.Decimal" )
myColumn.ReadOnly = True
myColumn.Expression = "UnitPrice * Quantity"
myColumn.Unique = False
End Sub |
|
C# |
VB |
DataColumn Members Unique AutoIncrement