DataViewRowState DataViewRowState DataViewRowState DataViewRowState Enum

정의

DataRow의 데이터 버전을 설명합니다.Describes the version of data in a DataRow.

이 열거형에는 멤버 값의 비트 조합을 허용하는 FlagsAttribute 특성이 있습니다.

public enum class DataViewRowState
[System.Flags]
public enum DataViewRowState
type DataViewRowState = 
Public Enum DataViewRowState
상속
DataViewRowStateDataViewRowStateDataViewRowStateDataViewRowState
특성

필드

Added Added Added Added 4

새 행입니다.A new row.

CurrentRows CurrentRows CurrentRows CurrentRows 22

변경되지 않은 행, 새 행 및 수정된 행을 포함한 현재 행입니다.Current rows including unchanged, new, and modified rows. 기본적으로 DataViewRowState는 CurrentRows로 설정됩니다.By default, DataViewRowState is set to CurrentRows.

Deleted Deleted Deleted Deleted 8

삭제된 행입니다.A deleted row.

ModifiedCurrent ModifiedCurrent ModifiedCurrent ModifiedCurrent 16

수정된 원래 데이터의 현재 버전입니다. ModifiedOriginal을 참조하십시오.A current version of original data that has been modified (see ModifiedOriginal).

ModifiedOriginal ModifiedOriginal ModifiedOriginal ModifiedOriginal 32

수정된 데이터의 원래 버전이며The original version of the data that was modified. 데이터가 수정되어 ModifiedCurrent로 사용할 수 있는 경우를 포함합니다.(Although the data has since been modified, it is available as ModifiedCurrent).

None None None None 0

없음None.

OriginalRows OriginalRows OriginalRows OriginalRows 42

변경되지 않은 행과 삭제된 행을 포함한 원본 행입니다.Original rows including unchanged and deleted rows.

Unchanged Unchanged Unchanged Unchanged 2

변경되지 않은 행입니다.An unchanged row.

예제

다음 예에서 DataTable 단일 열을 사용 하 여 만들어집니다.In the following example DataTable is created with a single column. 데이터는 변경 하며 RowStateFilterDataView 에 따라 다른 행 집합을 표시 하도록 설정 된는 DataViewRowState합니다.The data is changed, and the RowStateFilter of the DataView is set to display different row sets, depending on the DataViewRowState.

static private void DemonstrateRowState()
{
    // Create a DataTable with one column.
    DataTable dataTable = new DataTable("dataTable");
    DataColumn dataColumn = new DataColumn("dataColumn");
    dataTable.Columns.Add(dataColumn);

    // Add ten rows.
    DataRow dataRow;
    for (int i = 0; i < 10; i++)
    {
        dataRow = dataTable.NewRow();
        dataRow["dataColumn"] = "item " + i;
        dataTable.Rows.Add(dataRow);
    }
    dataTable.AcceptChanges();

    // Create a DataView with the table.
    DataView dataView = new DataView(dataTable);

    // Change one row's value:
    dataTable.Rows[1]["dataColumn"] = "Hello";

    // Add one row:
    dataRow = dataTable.NewRow();
    dataRow["dataColumn"] = "World";
    dataTable.Rows.Add(dataRow);

    // Set the RowStateFilter to display only added and modified rows.
    dataView.RowStateFilter = DataViewRowState.Added
        | DataViewRowState.ModifiedCurrent;

    // Print those rows. Output = "Hello" "World";
    PrintView(dataView, "ModifiedCurrent and Added");

    // Set filter to display on originals of modified rows.
    dataView.RowStateFilter = DataViewRowState.ModifiedOriginal;
    PrintView(dataView, "ModifiedOriginal");

    // Delete three rows.
    dataTable.Rows[1].Delete();
    dataTable.Rows[2].Delete();
    dataTable.Rows[3].Delete();

    // Set the RowStateFilter to display only Added and modified rows.
    dataView.RowStateFilter = DataViewRowState.Deleted;
    PrintView(dataView, "Deleted");

    //Set filter to display only current.
    dataView.RowStateFilter = DataViewRowState.CurrentRows;
    PrintView(dataView, "Current");

    // Set filter to display only unchanged rows.
    dataView.RowStateFilter = DataViewRowState.Unchanged;
    PrintView(dataView, "Unchanged");

    // Set filter to display only original rows.
    dataView.RowStateFilter = DataViewRowState.OriginalRows;
    PrintView(dataView, "OriginalRows");
}


static private void PrintView(DataView dataView, string label)
{
    Console.WriteLine("\n" + label);
    for (int i = 0; i < dataView.Count; i++)
    {
        Console.WriteLine(dataView[i]["dataColumn"]);
    }
}
Private Sub DemonstrateRowState()
    Dim i As Integer

    ' Create a DataTable with one column.
    Dim dataTable As New DataTable("dataTable")
    Dim dataColumn As New DataColumn("dataColumn")
    dataTable.Columns.Add(dataColumn)

    ' Add ten rows.
    Dim dataRow As DataRow
    For i = 0 To 9
        dataRow = dataTable.NewRow()
        dataRow("dataColumn") = "item " + i.ToString()
        dataTable.Rows.Add(dataRow)
    Next i
    dataTable.AcceptChanges()

    ' Create a DataView with the table.
    Dim dataView As New DataView(dataTable)

    ' Change one row's value:
    dataTable.Rows(1)("dataColumn") = "Hello"

    ' Add one row:
    dataRow = dataTable.NewRow()
    dataRow("dataColumn") = "World"
    dataTable.Rows.Add(dataRow)

    ' Set the RowStateFilter to display only Added and modified rows.
    dataView.RowStateFilter = _
    DataViewRowState.Added Or DataViewRowState.ModifiedCurrent

    ' Print those rows. Output = "Hello" "World";
    PrintView(dataView, "ModifiedCurrent and Added")

    ' Set filter to display on originals of modified rows.
    dataView.RowStateFilter = DataViewRowState.ModifiedOriginal
    PrintView(dataView, "ModifiedOriginal")

    ' Delete three rows.
    dataTable.Rows(1).Delete()
    dataTable.Rows(2).Delete()
    dataTable.Rows(3).Delete()

    ' Set the RowStateFilter to display only Added and modified rows.
    dataView.RowStateFilter = DataViewRowState.Deleted
    PrintView(dataView, "Deleted")

    'Set filter to display only current.
    dataView.RowStateFilter = DataViewRowState.CurrentRows
    PrintView(dataView, "Current")

    ' Set filter to display only unchanged rows.
    dataView.RowStateFilter = DataViewRowState.Unchanged
    PrintView(dataView, "Unchanged")

    ' Set filter to display only original rows.
    dataView.RowStateFilter = DataViewRowState.OriginalRows
    PrintView(dataView, "OriginalRows")
End Sub

Private Sub PrintView(ByVal dataView As DataView, ByVal label As String)
    Console.WriteLine(ControlChars.Cr + label)
    Dim i As Integer
    For i = 0 To dataView.Count - 1
        Console.WriteLine(dataView(i)("dataColumn"))
    Next i
End Sub

설명

DataViewRowState 값이 사용 됩니다 특정 버전의에서 데이터를 검색 하는 DataRow, 또는 어떤 버전이 있는지 확인 합니다.The DataViewRowState values are used either to retrieve a particular version of data from a DataRow, or to determine what versions exist.

설정 합니다 RowStateFilter 의 속성을 DataView 보려는 데이터의 버전을 지정 하 합니다.Set the RowStateFilter property of the DataView to specify which version or versions of data you want to view.

부울 연산자를 사용 하 여 또는 둘 이상의 버전을 가져올 값입니다.You can use the Boolean operator Or with the values to get more than one version.

합니다 DataTable 사용 하 여 DataViewRowStateSelect 메서드.The DataTable uses DataViewRowState in the Select method.

적용 대상

추가 정보