DataRowState DataRowState DataRowState DataRowState Enum

Definición

Obtiene el estado de un objeto DataRow.Gets the state of a DataRow object.

Esta enumeración tiene el atributo FlagsAttribute, que permite una combinación bit a bit de sus valores de miembro.

public enum class DataRowState
[System.Flags]
public enum DataRowState
type DataRowState = 
Public Enum DataRowState
Herencia
Atributos

Campos

Added Added Added Added 4

La fila se ha agregado a DataRowCollection y no se ha llamado a AcceptChanges().The row has been added to a DataRowCollection, and AcceptChanges() has not been called.

Deleted Deleted Deleted Deleted 8

La fila se ha eliminado mediante el método Delete() del DataRow.The row was deleted using the Delete() method of the DataRow.

Detached Detached Detached Detached 1

La fila se ha creado pero no forma parte de ninguna DataRowCollection.The row has been created but is not part of any DataRowCollection. DataRow se encuentra en este estado inmediatamente después de haber sido creado y antes de que se agregue a una colección, o bien si se ha quitado de una colección.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 Modified Modified Modified 16

La fila se ha modificado y no se ha llamado a AcceptChanges().The row has been modified and AcceptChanges() has not been called.

Unchanged Unchanged Unchanged Unchanged 2

La fila no ha cambiado desde la última vez que se llamó a AcceptChanges().The row has not changed since AcceptChanges() was last called.

Ejemplos

En el ejemplo siguiente se crea primero DataTable un nuevo con una columna y, a DataRowcontinuación, se crea un único.The following example first creates a new DataTable with one column, then creates a single DataRow. A medida que RowState secrea,agrega,modificayelimina,DataRow se imprime su.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

Comentarios

La DataRowState RowState propiedad de laDataRow clase devuelve la enumeración.The DataRowState enumeration is returned by the RowState property of the DataRow class.

Se aplica a

Consulte también: