本文整理匯總了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