DataColumn.ReadOnly Propriété

Définition

Obtient ou définit une valeur qui indique si la colonne autorise les modifications dès qu'une ligne a été ajoutée à la 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

Valeur de propriété

Boolean

true si la colonne est en lecture seule ; sinon, false. La valeur par défaut est false.

Attributs

Exceptions

La valeur de la propriété est false sur une colonne calculée.

Exemples

L’exemple suivant crée une DataColumn propriété et définit sa ReadOnly propriété 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

S’applique à

Voir aussi