DataRow.HasVersion(DataRowVersion) メソッド

定義

指定したバージョンが存在するかどうかを示す値を取得します。

public:
 bool HasVersion(System::Data::DataRowVersion version);
public bool HasVersion (System.Data.DataRowVersion version);
member this.HasVersion : System.Data.DataRowVersion -> bool
Public Function HasVersion (version As DataRowVersion) As Boolean

パラメーター

version
DataRowVersion

行のバージョンを指定する DataRowVersion 値の 1 つ。

戻り値

指定したバージョンが存在する場合は true。それ以外の場合は false

次の例では、 メソッドを HasVersion 使用して、列の現在の値と提案された値が同じかどうかを判断します。 その場合、編集は取り消されます。 それ以外の場合は、編集を AcceptChanges 終了するために メソッドが呼び出されます。

Private Sub CheckVersionBeforeAccept()
    ' Assuming the DataGrid is bound to a DataTable.
    Dim table As DataTable = CType(DataGrid1.DataSource, DataTable)
    Dim row As DataRow = table.Rows(DataGrid1.CurrentCell.RowNumber)
    row.BeginEdit
    row(1) = Edit1.Text
    If row.HasVersion(datarowversion.Proposed) Then
       If row(1, DataRowVersion.Current) Is _
            row(1, DataRowversion.Proposed) Then
          Console.WriteLine("The original and the proposed are the same")
          row.CancelEdit
          Exit Sub
       Else
          row.AcceptChanges
       End If
    Else
       Console.WriteLine("No new values proposed")
    End If
End Sub

注釈

詳細については、 BeginEdit メソッドを参照してください。

適用対象

こちらもご覧ください