DataColumn.ReadOnly 属性   
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置一个值,该值指示一旦向表中添加了行,列是否还允许更改。
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, setPublic Property ReadOnly As Boolean属性值
如果列为只读,则为 true;否则为 false。 默认值为 false。
- 属性
例外
对于计算所得的列,此属性设置为 false。
示例
以下示例创建 并 DataColumn 设置其 ReadOnly 属性 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