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 값 중 하나입니다.

반환

버전이 있으면 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 메서드를 참조하세요.

적용 대상

추가 정보