本文整理匯總了VB.NET中System.Data.DataViewRowState枚舉的典型用法代碼示例。如果您正苦於以下問題:VB.NET DataViewRowState枚舉的具體用法?VB.NET DataViewRowState怎麽用?VB.NET DataViewRowState使用的例子?那麽, 這裏精選的枚舉代碼示例或許可以為您提供幫助。
在下文中一共展示了DataViewRowState枚舉的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: DemonstrateRowState
Private Sub DemonstrateRowState()
Dim i As Integer
' Create a DataTable with one column.
Dim dataTable As New DataTable("dataTable")
Dim dataColumn As New DataColumn("dataColumn")
dataTable.Columns.Add(dataColumn)
' Add ten rows.
Dim dataRow As DataRow
For i = 0 To 9
dataRow = dataTable.NewRow()
dataRow("dataColumn") = "item " + i.ToString()
dataTable.Rows.Add(dataRow)
Next i
dataTable.AcceptChanges()
' Create a DataView with the table.
Dim dataView As New DataView(dataTable)
' Change one row's value:
dataTable.Rows(1)("dataColumn") = "Hello"
' Add one row:
dataRow = dataTable.NewRow()
dataRow("dataColumn") = "World"
dataTable.Rows.Add(dataRow)
' Set the RowStateFilter to display only Added and modified rows.
dataView.RowStateFilter = _
DataViewRowState.Added Or DataViewRowState.ModifiedCurrent
' Print those rows. Output = "Hello" "World";
PrintView(dataView, "ModifiedCurrent and Added")
' Set filter to display on originals of modified rows.
dataView.RowStateFilter = DataViewRowState.ModifiedOriginal
PrintView(dataView, "ModifiedOriginal")
' Delete three rows.
dataTable.Rows(1).Delete()
dataTable.Rows(2).Delete()
dataTable.Rows(3).Delete()
' Set the RowStateFilter to display only Added and modified rows.
dataView.RowStateFilter = DataViewRowState.Deleted
PrintView(dataView, "Deleted")
'Set filter to display only current.
dataView.RowStateFilter = DataViewRowState.CurrentRows
PrintView(dataView, "Current")
' Set filter to display only unchanged rows.
dataView.RowStateFilter = DataViewRowState.Unchanged
PrintView(dataView, "Unchanged")
' Set filter to display only original rows.
dataView.RowStateFilter = DataViewRowState.OriginalRows
PrintView(dataView, "OriginalRows")
End Sub
Private Sub PrintView(ByVal dataView As DataView, ByVal label As String)
Console.WriteLine(ControlChars.Cr + label)
Dim i As Integer
For i = 0 To dataView.Count - 1
Console.WriteLine(dataView(i)("dataColumn"))
Next i
End Sub