本文整理汇总了VB.NET中System.Data.DataRow.RejectChanges方法的典型用法代码示例。如果您正苦于以下问题:VB.NET DataRow.RejectChanges方法的具体用法?VB.NET DataRow.RejectChanges怎么用?VB.NET DataRow.RejectChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.DataRow
的用法示例。
在下文中一共展示了DataRow.RejectChanges方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: DemonstrateDeleteRow
Private Sub DemonstrateDeleteRow()
' Create a simple DataTable with two columns and ten rows.
Dim table As New DataTable("table")
Dim idColumn As New DataColumn("id", Type.GetType("System.Int32"))
idColumn.AutoIncrement = True
Dim itemColumn As New DataColumn("item", Type.GetType("System.String"))
table.Columns.Add(idColumn)
table.Columns.Add(itemColumn)
' Add ten rows.
Dim newRow As DataRow
Dim i As Integer
For i = 0 To 9
newRow = table.NewRow()
newRow("item") = "Item " & i.ToString()
table.Rows.Add(newRow)
Next i
table.AcceptChanges()
Dim itemColumns As DataRowCollection = table.Rows
itemColumns(0).Delete()
itemColumns(2).Delete()
itemColumns(3).Delete()
itemColumns(5).Delete()
Console.WriteLine(itemColumns(3).RowState.ToString())
' Reject changes on one deletion.
itemColumns(3).RejectChanges()
' Change the value of the column so it stands out.
itemColumns(3)("item") = "Deleted, Undeleted, Edited"
' Accept changes on others.
table.AcceptChanges()
' Print the remaining row values.
Dim row As DataRow
For Each row In table.Rows
Console.WriteLine(row(0).ToString() & ControlChars.Tab _
& row(1).ToString())
Next row
End Sub