本文整理汇总了VB.NET中System.Data.DataView.Sort属性的典型用法代码示例。如果您正苦于以下问题:VB.NET DataView.Sort属性的具体用法?VB.NET DataView.Sort怎么用?VB.NET DataView.Sort使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Data.DataView
的用法示例。
在下文中一共展示了DataView.Sort属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: Main
' 导入命名空间
Imports System.Data
Public Class A
Public Shared Sub Main(args As String())
Dim locationTable As New DataTable("Location")
' Add two columns
locationTable.Columns.Add("State")
locationTable.Columns.Add("ZipCode")
' Add data
locationTable.Rows.Add("Washington", "98052")
locationTable.Rows.Add("California", "90001")
locationTable.Rows.Add("Hawaii", "96807")
locationTable.Rows.Add("Hawaii", "96801")
locationTable.AcceptChanges()
Console.WriteLine("Rows in original order" & vbLf & " State " & vbTab & vbTab & " ZipCode")
For Each row As DataRow In locationTable.Rows
Console.WriteLine(" {0} " & vbTab & " {1}", row("State"), row("ZipCode"))
Next
' Create DataView
Dim view As New DataView(locationTable)
' Sort by State and ZipCode column in descending order
view.Sort = "State ASC, ZipCode ASC"
Console.WriteLine(vbLf & "Rows in sorted order" & vbLf & " State " & vbTab & vbTab & " ZipCode")
For Each row As DataRowView In view
Console.WriteLine(" {0} " & vbTab & " {1}", row("State"), row("ZipCode"))
Next
End Sub
End Class