DataColumn.ReadOnly Propiedad

Definición

Obtiene o establece un valor que indica si la columna permite cambios justo después de que se haya agregado una fila a la tabla.

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

Valor de propiedad

Boolean

true si la columna es de sólo lectura; en caso contrario, false. De manera predeterminada, es false.

Atributos

Excepciones

La propiedad está establecida en false en una columna calculada.

Ejemplos

En el ejemplo siguiente se crea un DataColumn objeto y se establece su ReadOnly propiedad 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

Se aplica a

Consulte también