本文整理匯總了VB.NET中System.Windows.Forms.BindingSource.Find方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET BindingSource.Find方法的具體用法?VB.NET BindingSource.Find怎麽用?VB.NET BindingSource.Find使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Windows.Forms.BindingSource
的用法示例。
在下文中一共展示了BindingSource.Find方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1:
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) _
Handles button1.Click
If binding1.SupportsSearching <> True Then
MessageBox.Show("Cannot search the list.")
Else
Dim foundIndex As Integer = binding1.Find("Name", textBox1.Text)
If foundIndex > -1 Then
listBox1.SelectedIndex = foundIndex
Else
MessageBox.Show("Font was not found.")
End If
End If
End Sub
End Class
示例2: PopulateDataViewAndFind
Private Sub PopulateDataViewAndFind()
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>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
' Set the Position property to the results of the Find method.
Dim itemFound As Integer = source1.Find("artist", "Natalie Merchant")
source1.Position = itemFound
End Sub