Morning everyone.
I have a simple form with a ListView (populated with about 2800 supplier names).
These names are resident in a dataset as a result of an SQL select statemet.
The user could simply scroll through the list of suppliers until he finds the one he is looking for (users are complaining that this takes too long) or they could select the ListView, then key in the first character of the supplier name and ListView will select the first supplier that starts with the character keyed in.
One character, however, is not enough. the users wish to be able to type more characters and get closer to the supplier name.
To achieve this I have included a "Quick Search" TextBox where they can do just that.
The plan is to take each character keyed in and select from the dataset into a DataRow (or dataRows) and get the Rowid/s and select or multiselect the matching items on the ListView.
The HUGE problem that I'm having is that I cannot seen to access the DataRow _Rowid (I can see it in debug mode)
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Ssql = "SELECT SP_Name from Supplier Where SP_Name <> ' Select Supplier' ORDER BY SP_Name"
da = New OleDb.OleDbDataAdapter(Ssql, cn)
da.Fill(ds, "Suppliers")
cn.Close()
For x = 0 To ds.Tables("Suppliers").Rows.Count - 1
ListView1.Items.Add(New ListViewItem(ds.Tables("Suppliers").Rows(x).Item(0).ToString))
Next
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Dim RowNumber As String
RowNumber = CStr(GetRowNumbers(TextBox1.Text))
End Sub
Private Function GetRowNumbers(ByVal theSupplier As String) As String
Dim Table As DataTable = ds.Tables("Suppliers")
Dim Expression As String
Dim FoundRows() As DataRow
Expression = "SP_Name LIKE '" & theSupplier & "%'"
FoundRows = Table.Select(Expression)
If FoundRows.Count = 0 Then
Return "Nothing Found"
else
Return CStr((FoundRows(0)(0)))
End If
End Function
Can anyone please advise how could do this.
Once again, many thanks.