Hi folks,
How can I change this code to work with partial search criteria?
This basically looks through the lines in a dataview and goes to the matching line from the search in txtfind.txt.
What I would like to be able to do here is to change the below to work as a filter instead with either a partial search criteria or maybe even use a wildcard in the middle i.e. "ms*1-07" will display the full search "ms27039-1-07"... Im currently at a loss as im still a novice at this...
Dim dt As DataTable = CType(Me.CrossRefDataGridView.DataSource, DataTable)
Dim cm As CurrencyManager = Me.BindingContext(dt)
Dim dr As DataRow
'CrossRefDataGridView.Sort(CrossRefDataGridView.Columns(0), System.ComponentModel.ListSortDirection.Ascending)
If RBCross.Checked Then
If dt.Select("[Cross-Reference No] ='" & (TxtFind.Text) & "'").Length > 0 Then
dr = dt.Select("[Cross-Reference No] ='" & (TxtFind.Text) & "'")(0)
Else
dr = Nothing
End If
Try
dr = dt.Select("[Cross-Reference No] ='" & (TxtFind.Text) & "'")(0)
Catch ex As Exception
End Try
If Not dr Is Nothing Then
For i As Integer = 0 To dt.Rows.Count - 1
If dt.Rows(i) Is dr Then
cm.Position = i
Exit For
End If
Next
Else
MessageBox.Show("row not found")
End If
dt = Nothing
cm = Nothing
dr = Nothing
End If
Thanks for your help
Dedo
How can I change this code to work with partial search criteria?
This basically looks through the lines in a dataview and goes to the matching line from the search in txtfind.txt.
What I would like to be able to do here is to change the below to work as a filter instead with either a partial search criteria or maybe even use a wildcard in the middle i.e. "ms*1-07" will display the full search "ms27039-1-07"... Im currently at a loss as im still a novice at this...
Dim dt As DataTable = CType(Me.CrossRefDataGridView.DataSource, DataTable)
Dim cm As CurrencyManager = Me.BindingContext(dt)
Dim dr As DataRow
'CrossRefDataGridView.Sort(CrossRefDataGridView.Columns(0), System.ComponentModel.ListSortDirection.Ascending)
If RBCross.Checked Then
If dt.Select("[Cross-Reference No] ='" & (TxtFind.Text) & "'").Length > 0 Then
dr = dt.Select("[Cross-Reference No] ='" & (TxtFind.Text) & "'")(0)
Else
dr = Nothing
End If
Try
dr = dt.Select("[Cross-Reference No] ='" & (TxtFind.Text) & "'")(0)
Catch ex As Exception
End Try
If Not dr Is Nothing Then
For i As Integer = 0 To dt.Rows.Count - 1
If dt.Rows(i) Is dr Then
cm.Position = i
Exit For
End If
Next
Else
MessageBox.Show("row not found")
End If
dt = Nothing
cm = Nothing
dr = Nothing
End If
Thanks for your help
Dedo