Gets a value indicating whether a specified version exists.
[Visual Basic] Public Function HasVersion( _ ByVal version As DataRowVersion _ ) As Boolean [C#] public bool HasVersion( DataRowVersion version ); [C++] public: bool HasVersion( DataRowVersion version ); [JScript] public function HasVersion( version : DataRowVersion ) : Boolean;
true if the version exists; otherwise, false.
See the BeginEdit method for more details.
[Visual Basic] The following example uses the HasVersion method to determine if the current value of a column and the proposed value are the same. If so, the edit is cancelled. Otherwise, the AcceptChanges method is called to end the edit.
[Visual Basic]
Private Sub CheckVersionBeforeAccept()
Dim r As DataRow
Dim t As DataTable
' Assuming the DataGrid is bound to a DataTable.
t = CType(DataGrid1.DataSource, DataTable)
r = t.Rows(DataGrid1.CurrentCell.RowNumber)
r.BeginEdit
r(1) = Edit1.Text
If r.HasVersion(datarowversion.Proposed) Then
If r(1, DataRowVersion.Current) Is r(1, DataRowversion.Proposed) Then
MessageBox.Show("The original and the proposed are the same")
r.CancelEdit
Exit Sub
Else
r.AcceptChanges
End If
Else
MessageBox.Show("No new values proposed")
End If
End Sub
[C#, C++, JScript] No example is available for C#, C++, or JScript. To view a Visual Basic example, click the Language Filter button
in the upper-left corner of the page.
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework - Windows CE .NET
DataRow Class | DataRow Members | System.Data Namespace | AcceptChanges | BeginEdit | CancelEdit | Item | GetChildRows | GetParentRows | EndEdit | RowState