다음을 통해 공유


DataColumn.ReadOnly 속성

테이블에 행을 추가한 후 열을 변경할 수 있는지 여부를 나타내는 값을 가져오거나 설정합니다.

네임스페이스: System.Data
어셈블리: System.Data(system.data.dll)

구문

‘선언
Public Property ReadOnly As Boolean
‘사용 방법
Dim instance As DataColumn
Dim value As Boolean

value = instance.ReadOnly

instance.ReadOnly = value
public bool ReadOnly { get; set; }
public:
property bool ReadOnly {
    bool get ();
    void set (bool value);
}
/** @property */
public boolean get_ReadOnly ()

/** @property */
public void set_ReadOnly (boolean value)
public function get ReadOnly () : boolean

public function set ReadOnly (value : boolean)

속성 값

열이 읽기 전용이면 true이고, 그렇지 않으면 false입니다. 기본값은 false입니다.

예외

예외 형식 조건

ArgumentException

속성이 계산 열에서 false로 설정된 경우

예제

다음 예제에서는 DataColumn을 만든 다음 ReadOnly 속성을 true로 설정합니다.

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
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;
}

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0, 1.0에서 지원

참고 항목

참조

DataColumn 클래스
DataColumn 멤버
System.Data 네임스페이스
Unique
DataColumn.AutoIncrement 속성