次の方法で共有


DataColumn.ReadOnly プロパティ

行がテーブルに追加された後でこの列を変更できるかどうかを示す値を取得または設定します。

Public Property ReadOnly As Boolean
[C#]
public bool ReadOnly {get; set;}
[C++]
public: __property bool get_ReadOnly();public: __property void set_ReadOnly(bool);
[JScript]
public function get ReadOnly() : Boolean;public function set ReadOnly(Boolean);

プロパティ値

列が読み取り専用の場合は true 。それ以外の場合は false 。既定値は false です。

例外

例外の種類 条件
ArgumentException このプロパティは計算列に対して false に設定されます。

使用例

[Visual Basic, C#, C++] DataColumn を作成し、この列の ReadOnly プロパティを true に設定する例を次に示します。

 
Private Sub AddColumn(ByVal myTable As DataTable)
    ' Add a DataColumn to the collection and set its properties.
    Dim myColumn As DataColumn
    ' The constructor sets the ColumnName of the column.
    myColumn = myTable.Columns.Add("Total")
    myColumn.DataType = System.Type.GetType("System.Decimal")
    myColumn.ReadOnly = True
    myColumn.Expression = "UnitPrice * Quantity"
    myColumn.Unique = False
 End Sub

[C#] 
private void AddColumn(DataTable myTable){
    // Add a DataColumn to the collection and set its properties.
    DataColumn myColumn;
    // The constructor sets the ColumnName of the column.
    myColumn = myTable.Columns.Add("Total");
    myColumn.DataType = System.Type.GetType("System.Decimal");
    myColumn.ReadOnly = true;
    myColumn.Expression = "UnitPrice * Quantity";
    myColumn.Unique = false;
 }

[C++] 
private:
void AddColumn(DataTable* myTable){
    // Add a DataColumn to the collection and set its properties.
    DataColumn* myColumn;
    // The constructor sets the ColumnName of the column.
    myColumn = myTable->Columns->Add(S"Total");
    myColumn->DataType = System::Type::GetType(S"System.Decimal");
    myColumn->ReadOnly = true;
    myColumn->Expression = S"UnitPrice * Quantity";
    myColumn->Unique = false;
}

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET

参照

DataColumn クラス | DataColumn メンバ | System.Data 名前空間 | Unique | AutoIncrement