本文整理匯總了VB.NET中System.Windows.Forms.BindingSource.Sort屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET BindingSource.Sort屬性的具體用法?VB.NET BindingSource.Sort怎麽用?VB.NET BindingSource.Sort使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.Windows.Forms.BindingSource
的用法示例。
在下文中一共展示了BindingSource.Sort屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: PopulateDataViewAndSort
Private Sub PopulateDataViewAndSort()
Dim set1 As New DataSet()
' Some xml data to populate the DataSet with.
Dim musicXml As String = "<?xml version='1.0' encoding='UTF-8'?>" & _
"<music>" & _
"<recording><artist>Coldplay</artist><cd>X&Y</cd></recording>" & _
"<recording><artist>Dave Matthews</artist><cd>Under the Table and Dreaming</cd></recording>" & _
"<recording><artist>Dave Matthews</artist><cd>Live at Red Rocks</cd></recording>" & _
"<recording><artist>Natalie Merchant</artist><cd>Tigerlily</cd></recording>" & _
"<recording><artist>U2</artist><cd>How to Dismantle an Atomic Bomb</cd></recording>" & _
"</music>"
' Read the xml.
Dim reader As New StringReader(musicXml)
set1.ReadXml(reader)
' Get a DataView of the table contained in the dataset.
Dim tables As DataTableCollection = set1.Tables
Dim view1 As New DataView(tables(0))
' Create a DataGridView control and add it to the form.
Dim datagridview1 As New DataGridView()
datagridview1.AutoGenerateColumns = True
Me.Controls.Add(datagridview1)
' Create a BindingSource and set its DataSource property to
' the DataView.
Dim source1 As New BindingSource()
source1.DataSource = view1
' Set the data source for the DataGridView.
datagridview1.DataSource = source1
source1.Sort = "cd"
End Sub
示例2: PopulateDataViewAndAdvancedSort
Private Sub PopulateDataViewAndAdvancedSort()
Dim set1 As New DataSet()
' Some xml data to populate the DataSet with.
Dim musicXml As String = "<?xml version='1.0' encoding='UTF-8'?>" & _
"<music>" & _
"<recording><artist>Dave Matthews</artist><cd>Under the Table and Dreaming</cd></recording>" & _
"<recording><artist>Coldplay</artist><cd>X&Y</cd></recording>" & _
"<recording><artist>Dave Matthews</artist><cd>Live at Red Rocks</cd></recording>" & _
"<recording><artist>U2</artist><cd>Joshua Tree</cd></recording>" & _
"<recording><artist>U2</artist><cd>How to Dismantle an Atomic Bomb</cd></recording>" & _
"<recording><artist>Natalie Merchant</artist><cd>Tigerlily</cd></recording>" & _
"</music>"
' Read the xml.
Dim reader As New StringReader(musicXml)
set1.ReadXml(reader)
' Get a DataView of the table contained in the dataset.
Dim tables As DataTableCollection = set1.Tables
Dim view1 As New DataView(tables(0))
' Create a DataGridView control and add it to the form.
Dim datagridview1 As New DataGridView()
datagridview1.AutoGenerateColumns = True
Me.Controls.Add(datagridview1)
' Create a BindingSource and set its DataSource property to
' the DataView.
Dim source1 As New BindingSource()
source1.DataSource = view1
' Set the data source for the DataGridView.
datagridview1.DataSource = source1
source1.Sort = "artist ASC, cd ASC"