DataRowState 列挙型


DataRow オブジェクトの状態を取得します。Gets the state of a DataRow object.

この列挙体には FlagsAttribute 属性があり、そのメンバー値のビットごとの組み合わせが可能になります。

public enum class DataRowState
public enum DataRowState
public enum DataRowState
type DataRowState = 
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 1 つの列で新しいを作成し、次に1つのを作成し 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);

   // New row.
   Console.WriteLine("AddRow " + myRow.RowState);

   // Unchanged row.
   Console.WriteLine("AcceptChanges " + myRow.RowState);

   myRow["FirstName"] = "Scott";
   // Modified row.
   Console.WriteLine("Modified " + myRow.RowState);

   // 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"));
   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))

    ' New row.
    Console.WriteLine(String.Format("AddRow {0}", dataRow.RowState))

    ' Unchanged row.
    Console.WriteLine(String.Format("AcceptChanges {0}", dataRow.RowState))

    dataRow("FirstName") = "Scott"
    ' Modified row.
    Console.WriteLine(String.Format("Modified {0}", dataRow.RowState))

    ' 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", _
    Return dt
End Function


DataRowState 列挙は、RowState クラスの DataRow プロパティによって返されます。The DataRowState enumeration is returned by the RowState property of the DataRow class.