다음을 통해 공유


DataRowView 클래스

정의

에 대한 사용자 지정된 보기를 DataRow나타냅니다.

public ref class DataRowView : System::ComponentModel::ICustomTypeDescriptor, System::ComponentModel::IDataErrorInfo, System::ComponentModel::IEditableObject, System::ComponentModel::INotifyPropertyChanged
public ref class DataRowView : System::ComponentModel::ICustomTypeDescriptor, System::ComponentModel::IDataErrorInfo, System::ComponentModel::IEditableObject
public class DataRowView : System.ComponentModel.ICustomTypeDescriptor, System.ComponentModel.IDataErrorInfo, System.ComponentModel.IEditableObject, System.ComponentModel.INotifyPropertyChanged
public class DataRowView : System.ComponentModel.ICustomTypeDescriptor, System.ComponentModel.IDataErrorInfo, System.ComponentModel.IEditableObject
type DataRowView = class
    interface ICustomTypeDescriptor
    interface IDataErrorInfo
    interface IEditableObject
    interface INotifyPropertyChanged
type DataRowView = class
    interface ICustomTypeDescriptor
    interface IEditableObject
    interface IDataErrorInfo
type DataRowView = class
    interface ICustomTypeDescriptor
    interface IEditableObject
    interface IDataErrorInfo
    interface INotifyPropertyChanged
Public Class DataRowView
Implements ICustomTypeDescriptor, IDataErrorInfo, IEditableObject, INotifyPropertyChanged
Public Class DataRowView
Implements ICustomTypeDescriptor, IDataErrorInfo, IEditableObject
상속
DataRowView
구현

예제

다음 예제에서는 속성을 사용 하 여 RowVersion 행의 상태를 확인 합니다 DataRowView. (.를 사용하는 DataRowView다른 예제를 참조하세요RowFilter.)

private static void DemonstrateRowVersion()
{
    // Create a DataTable with one column.
    DataTable table = new DataTable("Table");
    DataColumn column = new DataColumn("Column");
    table.Columns.Add(column);

    // Add ten rows.
    DataRow row;
    for (int i = 0; i < 10; i++)
    {
        row = table.NewRow();
        row["Column"] = "item " + i;
        table.Rows.Add(row);
    }

    table.AcceptChanges();
    // Create a DataView with the table.
    DataView view = new DataView(table);

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

    // Add one row:
    row = table.NewRow();
    row["Column"] = "World";
    table.Rows.Add(row);

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

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

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

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

    // Set the RowStateFilter to display only deleted rows.
    view.RowStateFilter = DataViewRowState.Deleted;
    PrintView(view, "Deleted");

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

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

    // Set filter to display only original rows.
    // Current values of unmodified rows are also returned.
    view.RowStateFilter = DataViewRowState.OriginalRows;
    PrintView(view, "OriginalRows");
}

private static void PrintView(DataView view, string label)
{
    Console.WriteLine("\n" + label);
    for (int i = 0; i < view.Count; i++)
    {
        Console.WriteLine(view[i]["Column"]);
        Console.WriteLine("DataViewRow.RowVersion: {0}",
            view[i].RowVersion);
    }
}
Private Sub DemonstrateRowVersion()
    Dim i As Integer
    ' Create a DataTable with one column.
    Dim table As New DataTable("Table")
    Dim column As New DataColumn("Column")
    table.Columns.Add(column)

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

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

    ' Change one row's value:
    table.Rows(1)("Column") = "Hello"

    ' Add one row:
    row = table.NewRow()
    row("Column") = "World"
    table.Rows.Add(row)

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

    ' Print those rows. Output includes "Hello" and "World".
    PrintView(view, "ModifiedCurrent and Added")

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

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

    ' Set the RowStateFilter to display only deleted rows.
    view.RowStateFilter = DataViewRowState.Deleted
    PrintView(view, "Deleted")

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

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

    ' Set filter to display only original rows.
    ' Current values of unmodified rows are also returned.
    view.RowStateFilter = DataViewRowState.OriginalRows
    PrintView(view, "OriginalRows")
End Sub

Private Sub PrintView(ByVal view As DataView, ByVal label As String)
    Console.WriteLine(ControlChars.Cr + label)
    Dim i As Integer
    For i = 0 To view.Count - 1
        Console.WriteLine(view(i)("Column"))
        Console.WriteLine("DataRowView.RowVersion: {0}", _
            view(i).RowVersion)
    Next i
End Sub

설명

컨트롤과 같이 DataGrid 데이터가 표시될 때마다 각 행의 버전 하나만 표시할 수 있습니다. 표시된 행은 .입니다 DataRowView.

A DataRowView 는 네 가지 버전 상태 중 하나를 가질 수 있습니다. Default, Original, CurrentProposed.

호출한 BeginEditDataRow후 편집된 모든 값이 값이 Proposed 됩니다. 둘 중 하나 CancelEdit 또는 EndEdit 호출될 때까지 행에는 버전과 버전이 Original 있습니다 Proposed . CancelEdit 호출되면 제안된 버전이 삭제되고 값이 .로 Original되돌아갑니다. 호출된 DataRowView 경우 EndEdit 더 이상 버전이 Proposed 없습니다. 대신 제안된 값이 현재 값이 됩니다. 기본값은 기본값이 정의된 열이 있는 행에서만 사용할 수 있습니다.

속성

Name Description
DataView

이 행이 DataView 속한 행을 가져옵니다.

IsEdit

행이 편집 모드에 있는지 여부를 나타냅니다.

IsNew

DataRowView 항목인지 여부를 나타냅니다.

Item[Int32]

지정된 열의 값을 가져오거나 설정합니다.

Item[String]

지정된 열의 값을 가져오거나 설정합니다.

Row

볼 수 있는 값을 DataRow 가져옵니다.

RowVersion

에 대한 현재 버전 설명을 DataRow가져옵니다.

메서드

Name Description
BeginEdit()

편집 절차를 시작합니다.

CancelEdit()

편집 절차를 취소합니다.

CreateChildView(DataRelation, Boolean)

DataView 지정 DataRelation 한 자식과 부모가 있는 자식 DataTable 에 대한 값을 반환합니다.

CreateChildView(DataRelation)

DataView 지정된 자식이 있는 자식 DataTable 에 대한 값을 DataRelation반환합니다.

CreateChildView(String, Boolean)

DataView 지정된 DataRelation 이름과 부모가 있는 자식 DataTable 에 대한 값을 반환합니다.

CreateChildView(String)

DataView 지정된 자식 이름을 가진 자식 DataTableDataRelation 에 대한 값을 반환합니다.

Delete()

행을 삭제합니다.

EndEdit()

기본 DataRow 변경 내용을 커밋하고 BeginEdit(). 에 대한 변경 내용을 취소하는 데 DataRow사용합니다CancelEdit().

Equals(Object)

현재 DataRowView 가 지정된 개체와 동일한지 여부를 나타내는 값을 가져옵니다.

GetHashCode()

개체의 해시 코드를 DataRow 반환합니다.

GetType()

현재 인스턴스의 Type 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

이벤트

Name Description
PropertyChanged

속성이 변경될 때 DataRowView 발생하는 이벤트입니다.

명시적 인터페이스 구현

Name Description
ICustomTypeDescriptor.GetAttributes()

구성 요소의 이 인스턴스에 대한 사용자 지정 특성 컬렉션을 반환합니다.

ICustomTypeDescriptor.GetClassName()

구성 요소 인스턴스의 클래스 이름을 반환합니다.

ICustomTypeDescriptor.GetComponentName()

구성 요소의 이 인스턴스 이름을 반환합니다.

ICustomTypeDescriptor.GetConverter()

구성 요소의 이 인스턴스에 대한 형식 변환기를 반환합니다.

ICustomTypeDescriptor.GetDefaultEvent()

구성 요소의 이 인스턴스에 대한 기본 이벤트를 반환합니다.

ICustomTypeDescriptor.GetDefaultProperty()

구성 요소의 이 인스턴스에 대한 기본 속성을 반환합니다.

ICustomTypeDescriptor.GetEditor(Type)

구성 요소의 이 인스턴스에 대해 지정된 형식의 편집기를 반환합니다.

ICustomTypeDescriptor.GetEvents()

구성 요소의 이 인스턴스에 대한 이벤트를 반환합니다.

ICustomTypeDescriptor.GetEvents(Attribute[])

지정된 특성이 있는 구성 요소의 이 인스턴스에 대한 이벤트를 반환합니다.

ICustomTypeDescriptor.GetProperties()

구성 요소의 이 인스턴스에 대한 속성을 반환합니다.

ICustomTypeDescriptor.GetProperties(Attribute[])

지정된 특성이 있는 구성 요소의 이 인스턴스에 대한 속성을 반환합니다.

ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor)

지정된 속성 설명자가 설명하는 속성을 포함하는 개체를 반환합니다.

IDataErrorInfo.Error

개체에 대한 유효성 검사 오류를 설명하는 메시지를 가져옵니다.

IDataErrorInfo.Item[String]

지정된 이름의 속성에 대한 오류 메시지를 가져옵니다.

적용 대상

스레드 보안

이 형식은 다중 스레드 읽기 작업에 안전합니다. 모든 쓰기 작업을 동기화해야 합니다.

추가 정보