Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

DataColumn.ReadOnly Property

Definition

Namespace:
System.Data
Assemblies:
netstandard.dll, System.Data.Common.dll
Assembly:
System.Data.Common.dll
Assembly:
System.Data.dll
Assembly:
netstandard.dll
Source:
DataColumn.cs
Source:
DataColumn.cs
Source:
DataColumn.cs
Source:
DataColumn.cs
Source:
DataColumn.cs

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Gets or sets a value that indicates whether the column allows for changes as soon as a row has been added to the table.

public:
 property bool ReadOnly { bool get(); void set(bool value); };
public bool ReadOnly { get; set; }
[System.Data.DataSysDescription("DataColumnReadOnlyDescr")]
public bool ReadOnly { get; set; }
member this.ReadOnly : bool with get, set
[<System.Data.DataSysDescription("DataColumnReadOnlyDescr")>]
member this.ReadOnly : bool with get, set
Public Property ReadOnly As Boolean

Property Value

true if the column is read only; otherwise, false. The default is false.

Attributes

Exceptions

The property is set to false on a computed column.

Examples

The following example creates a DataColumn and sets its ReadOnly property true.

private void AddColumn(DataTable table)
{
 // Add a DataColumn to the collection and set its properties.
 // The constructor sets the ColumnName of the column.
 DataColumn column = table.Columns.Add("Total");
 column.DataType = System.Type.GetType("System.Decimal");
 column.ReadOnly = true;
 column.Expression = "UnitPrice * Quantity";
 column.Unique = false;
}
Private Sub AddColumn(ByVal table As DataTable)
 ' Add a DataColumn to the collection and set its properties.
 ' The constructor sets the ColumnName of the column.
 Dim column As DataColumn = table.Columns.Add("Total")
 column.DataType = System.Type.GetType("System.Decimal")
 column.ReadOnly = True
 column.Expression = "UnitPrice * Quantity"
 column.Unique = False
End Sub

Applies to

See also


Feedback

Was this page helpful?