DataColumn.ReadOnly Eigenschaft
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Dient zum Abrufen oder Festlegen eines Werts, der angibt, ob die Spalte Änderungen zulässt, sobald der Tabelle eine Zeile hinzugefügt wurde.
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
Eigenschaftswert
truewenn die Spalte schreibgeschützt ist; andernfalls . false Der Standardwert lautet false.
- Attribute
Ausnahmen
Die Eigenschaft wird für eine berechnete Spalte festgelegt false .
Beispiele
Im folgenden Beispiel wird eine DataColumn Eigenschaft trueerstellt und festgelegtReadOnly.
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