DataRowState 열거형
정의
DataRow 개체의 상태를 가져옵니다.Gets the state of a DataRow object.
이 열거형에는 멤버 값의 비트 조합을 허용하는 FlagsAttribute 특성이 있습니다.
public enum class DataRowState
[System.Flags]
public enum DataRowState
[<System.Flags>]
type DataRowState =
Public Enum DataRowState
- 상속
- 특성
필드
Added | 4 | 행이 DataRowCollection에 추가되었으며 AcceptChanges()는 호출되지 않았습니다.The row has been added to a DataRowCollection, and AcceptChanges() has not been called. |
Deleted | 8 | Delete()의 DataRow 메서드를 사용하여 행을 삭제했습니다.The row was deleted using the Delete() method of the DataRow. |
Detached | 1 | 행이 만들어졌지만 DataRowCollection의 일부는 아닙니다.The row has been created but is not part of any DataRowCollection. DataRow는 만들어진 직후 및 컬렉션에 추가되기 전 또는 컬렉션에서 제거된 경우 이 상태가 됩니다.A DataRow is in this state immediately after it has been created and before it is added to a collection, or if it has been removed from a collection. |
Modified | 16 | 행이 수정되었으며 AcceptChanges()는 호출되지 않았습니다.The row has been modified and AcceptChanges() has not been called. |
Unchanged | 2 | AcceptChanges()가 마지막으로 호출된 이후에 행이 변경되지 않았습니다.The row has not changed since AcceptChanges() was last called. |
예제
다음 예에서는 먼저 DataTable 하나의 열이 있는 새를 만든 다음 단일을 만듭니다 DataRow .The following example first creates a new DataTable with one column, then creates a single DataRow. DataRow가 생성, 추가, 수정 및 삭제 되 면 RowState 이 인쇄 됩니다.As the DataRow is created, added, modified, and deleted, its RowState is printed.
private void DemonstrateRowState() {
//Run a function to create a DataTable with one column.
DataTable myTable = MakeTable();
DataRow myRow;
// Create a new DataRow.
myRow = myTable.NewRow();
// Detached row.
Console.WriteLine("New Row " + myRow.RowState);
myTable.Rows.Add(myRow);
// New row.
Console.WriteLine("AddRow " + myRow.RowState);
myTable.AcceptChanges();
// Unchanged row.
Console.WriteLine("AcceptChanges " + myRow.RowState);
myRow["FirstName"] = "Scott";
// Modified row.
Console.WriteLine("Modified " + myRow.RowState);
myRow.Delete();
// Deleted row.
Console.WriteLine("Deleted " + myRow.RowState);
}
private DataTable MakeTable(){
// Make a simple table with one column.
DataTable dt = new DataTable("myTable");
DataColumn dcFirstName = new DataColumn("FirstName", Type.GetType("System.String"));
dt.Columns.Add(dcFirstName);
return dt;
}
Private Sub DemonstrateRowState()
'Run a function to create a DataTable with one column.
Dim dataTable As DataTable = MakeTable()
Dim dataRow As DataRow
' Create a new DataRow.
dataRow = dataTable.NewRow()
' Detached row.
Console.WriteLine(String.Format("New Row {0}", dataRow.RowState))
dataTable.Rows.Add(dataRow)
' New row.
Console.WriteLine(String.Format("AddRow {0}", dataRow.RowState))
dataTable.AcceptChanges()
' Unchanged row.
Console.WriteLine(String.Format("AcceptChanges {0}", dataRow.RowState))
dataRow("FirstName") = "Scott"
' Modified row.
Console.WriteLine(String.Format("Modified {0}", dataRow.RowState))
dataRow.Delete()
' Deleted row.
Console.WriteLine(String.Format("Deleted {0}", dataRow.RowState))
End Sub
Private Function MakeTable() As DataTable
' Make a simple table with one column.
Dim dt As New DataTable("dataTable")
Dim firstName As New DataColumn("FirstName", _
Type.GetType("System.String"))
dt.Columns.Add(firstName)
Return dt
End Function
설명
DataRowState열거형은 RowState 클래스의 속성에서 반환 됩니다 DataRow .The DataRowState enumeration is returned by the RowState property of the DataRow class.