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 データが表示されるたびに、各行の 1 つのバージョンのみを表示できます。 表示される行は です DataRowView

にはDataRowView、および Proposedの 4 つの異なるバージョン状態DefaultOriginalCurrentのいずれかを指定できます。

DataRowBeginEdit呼び出すと、編集された値が値になりますProposed。 または がCancelEdit呼び出されるまで、行には Original バージョンと バージョンがありますProposedEndEdit CancelEditが呼び出されると、提案されたバージョンは破棄され、値は にOriginal戻ります。 が呼び出された場合 EndEditDataRowView にはバージョンがありません Proposed 。代わりに、提案された値が現在の値になります。 既定値は、既定値が定義されている列がある行でのみ使用できます。

プロパティ

DataView

この行が属する DataView を取得します。

IsEdit

行が編集モードかどうかを示します。

IsNew

DataRowView が新しいかどうかを示します。

Item[Int32]

指定した列の値を取得または設定します。

Item[String]

指定した列の値を取得または設定します。

Row

表示されている DataRow を取得します。

RowVersion

DataRow の現在のバージョンの説明を取得します。

メソッド

BeginEdit()

編集プロシージャを開始します。

CancelEdit()

編集プロシージャをキャンセルします。

CreateChildView(DataRelation)

指定した子 DataView を使用して子 DataTableDataRelation を返します。

CreateChildView(DataRelation, Boolean)

指定した DataRelation と親を使用して子 DataTableDataView を返します。

CreateChildView(String)

指定した子 DataView 名を使用して子 DataTableDataRelation を返します。

CreateChildView(String, Boolean)

指定した DataView 名と親を使用して子 DataTableDataRelation を返します。

Delete()

行を削除します。

EndEdit()

DataRow に対する変更をコミットし、BeginEdit() によって開始された編集セッションを終了します。 CancelEdit() への変更を破棄するには、DataRow を使用します。

Equals(Object)

現在の DataRowView が指定したオブジェクトと同一かどうかを示す値を取得します。

GetHashCode()

DataRow オブジェクトのハッシュ コードを返します。

GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

イベント

PropertyChanged

DataRowView プロパティの変更時に発生するイベント。

明示的なインターフェイスの実装

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]

指定した名前のプロパティに関するエラー メッセージを取得します。

適用対象

スレッド セーフ

この型は、マルチスレッド読み取り操作に対して安全です。 すべての書き込み操作を同期する必要があります。

こちらもご覧ください