展开全部
每当显示数据时(如在 DataGrid 控件中),仅可以显示每行的一个版本。所显示的行是 DataRowView。
DataRowView 可以具有以下四个不同的版本状态之一:Default、Original、Current 和 Proposed。
在针对 DataRow 调用 BeginEdit 之后,任何已编辑的值变成 Proposed 值。在调用 CancelEdit 或 EndEdit 之前,行有一个 Original 和一个 Proposed 版本。如果调用了 CancelEdit,建议的版本将被丢弃,值将恢复为 Original。如果调用了 EndEdit,DataRowView 将不再具有 Proposed 版本;相反,建议的值将变为当前值。默认值只在那些列具有已定义的默认值的行上可用。
示例
--------------------------------------------------------------------------------
下面的示例使用 RowVersion 属性确定 DataRowView 中行的状态。
VBC#C++F#JScript
复制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
继承层次结构
--------------------------------------------------------------------------------
System.Object
System.Data.DataRowView
线程安全
--------------------------------------------------------------------------------
该类型对于多线程读操作是安全的。您必须使任何写操作同步。
平台
--------------------------------------------------------------------------------
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
DataRowView 可以具有以下四个不同的版本状态之一:Default、Original、Current 和 Proposed。
在针对 DataRow 调用 BeginEdit 之后,任何已编辑的值变成 Proposed 值。在调用 CancelEdit 或 EndEdit 之前,行有一个 Original 和一个 Proposed 版本。如果调用了 CancelEdit,建议的版本将被丢弃,值将恢复为 Original。如果调用了 EndEdit,DataRowView 将不再具有 Proposed 版本;相反,建议的值将变为当前值。默认值只在那些列具有已定义的默认值的行上可用。
示例
--------------------------------------------------------------------------------
下面的示例使用 RowVersion 属性确定 DataRowView 中行的状态。
VBC#C++F#JScript
复制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
继承层次结构
--------------------------------------------------------------------------------
System.Object
System.Data.DataRowView
线程安全
--------------------------------------------------------------------------------
该类型对于多线程读操作是安全的。您必须使任何写操作同步。
平台
--------------------------------------------------------------------------------
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
展开全部
每当显示数据时(如在 DataGrid 控件中),仅可以显示每行的一个版本。 所显示的行是 DataRowView。
DataRowView 可以具有以下四个不同的版本状态之一: Default、 Original、 Current 和 Proposed。
在针对 DataRow 调用 BeginEdit 之后,任何已编辑的值变成 Proposed 值。 在调用 CancelEdit 或 EndEdit 之前,行有一个 Original 和一个 Proposed 版本。 如果调用了 CancelEdit,建议的版本将被丢弃,值将恢复为 Original。 如果调用了 EndEdit, DataRowView 将不再具有 Proposed 版本;相反,建议的值将变为当前值。 默认值只在那些列具有已定义的默认值的行上可用。
DataRowView 可以具有以下四个不同的版本状态之一: Default、 Original、 Current 和 Proposed。
在针对 DataRow 调用 BeginEdit 之后,任何已编辑的值变成 Proposed 值。 在调用 CancelEdit 或 EndEdit 之前,行有一个 Original 和一个 Proposed 版本。 如果调用了 CancelEdit,建议的版本将被丢弃,值将恢复为 Original。 如果调用了 EndEdit, DataRowView 将不再具有 Proposed 版本;相反,建议的值将变为当前值。 默认值只在那些列具有已定义的默认值的行上可用。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询