DataRow.HasVersion 方法

获取一个值,该值指示指定的版本是否存在。

**命名空间:**System.Data
**程序集:**System.Data(在 system.data.dll 中)

语法

声明
Public Function HasVersion ( _
    version As DataRowVersion _
) As Boolean
用法
Dim instance As DataRow
Dim version As DataRowVersion
Dim returnValue As Boolean

returnValue = instance.HasVersion(version)
public bool HasVersion (
    DataRowVersion version
)
public:
bool HasVersion (
    DataRowVersion version
)
public boolean HasVersion (
    DataRowVersion version
)
public function HasVersion (
    version : DataRowVersion
) : boolean

参数

返回值

如果版本存在,则为 true;否则为 false

备注

有关更多信息,请参见 BeginEdit 方法。

示例

下面的示例使用 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

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

.NET Compact Framework

受以下版本支持:2.0、1.0

请参见

参考

DataRow 类
DataRow 成员
System.Data 命名空间
AcceptChanges
BeginEdit
CancelEdit
Item
GetChildRows
GetParentRows
EndEdit
RowState