DataColumn.ReadOnly DataColumn.ReadOnly DataColumn.ReadOnly DataColumn.ReadOnly Property

定義

行がテーブルに追加された直後にこの列を変更できるかどうかを示す値を取得または設定します。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); };
[System.Data.DataSysDescription("DataColumnReadOnlyDescr")]
public bool ReadOnly { get; set; }
member this.ReadOnly : bool with get, set
Public Property ReadOnly As Boolean

プロパティ値

列が読み取り専用の場合は true。それ以外の場合は falsetrue if the column is read only; otherwise, false. 既定値は、false です。The default is false.

例外

このプロパティは計算列に対して false に設定されます。The property is set to false on a computed column.

次の例ではDataColumn 、を作成ReadOnlytrue、そのプロパティを設定します。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

適用対象

こちらもご覧ください