Hello All, I have found several snipetts of code to search a Listview but they all seem to only search the first column. Has anyone seen a way to search the 2nd 3rd etc. columns data? Heres what I have so far
Code:
'in LVvb.vb class file
' See LVFindTest for parm definitions
PublicSub LVFnd(ByRef lv As ListView, ByVal ss AsString, _
OptionalByVal flag AsInteger = LVFI_PARTIAL)
Dim xFindInfo As LVFINDINFO = New LVFINDINFO
xFindInfo.flags = Convert.ToUInt32(flag)
xFindInfo.psz = ss
Dim index AsInteger = SendMessage(lv.Handle, Convert.ToUInt32(LVM_FINDITEM), -1, xFindInfo)
If index > -1 Then
lv.Items(index).Selected = True
lv.Items(index).Focused = True
EndIf
EndSub
' See LVFindTest for parm definitions
PublicFunction GetSubItemRect(ByRef lv As ListView, ByVal iItem AsInteger, _
ByVal sItem AsInteger, OptionalByVal flag AsInteger = LVIR_BOUNDS) As Rectangle
Dim lpRect As RECT = New RECT
With lpRect
.top = sItem : .left = flag
Dim result AsInteger = SendMessage(lv.Handle, Convert.ToUInt32(LVM_GETSUBITEMRECT), iItem, lpRect)
If result = 0 Then
ReturnNew Rectangle(0, 0, 0, 0)
Else
Return Rectangle.FromLTRB(.left, .top, .right, .bottom)
EndIf
EndWith
EndFunction
''' In Button3 Click Event
Dim fPar AsInteger = Lvfind.LVFindItem.LVFI_PARTIAL
' Clear any selection in the ListView control
' ClearSelection()
' Make an instance of the LVFindItem class
Dim lvf AsNew LVFind.LVFindItem
' Call the LVFnd() sub
' 1st parm is ListView control
' 2nd parm is text to find
' 3rd parm is flag value (see LVFind class for definition)
lvf.LVFnd(ListView1, TextBox5.Text, fPar)
' Focus the ListView control so we can see which item is selected
ListView1.Focus()
Again I can only search the first colum of data.......... need to search the 3rd column actually. Thanks in advance
Dave
Code:
'in LVvb.vb class file
' See LVFindTest for parm definitions
PublicSub LVFnd(ByRef lv As ListView, ByVal ss AsString, _
OptionalByVal flag AsInteger = LVFI_PARTIAL)
Dim xFindInfo As LVFINDINFO = New LVFINDINFO
xFindInfo.flags = Convert.ToUInt32(flag)
xFindInfo.psz = ss
Dim index AsInteger = SendMessage(lv.Handle, Convert.ToUInt32(LVM_FINDITEM), -1, xFindInfo)
If index > -1 Then
lv.Items(index).Selected = True
lv.Items(index).Focused = True
EndIf
EndSub
' See LVFindTest for parm definitions
PublicFunction GetSubItemRect(ByRef lv As ListView, ByVal iItem AsInteger, _
ByVal sItem AsInteger, OptionalByVal flag AsInteger = LVIR_BOUNDS) As Rectangle
Dim lpRect As RECT = New RECT
With lpRect
.top = sItem : .left = flag
Dim result AsInteger = SendMessage(lv.Handle, Convert.ToUInt32(LVM_GETSUBITEMRECT), iItem, lpRect)
If result = 0 Then
ReturnNew Rectangle(0, 0, 0, 0)
Else
Return Rectangle.FromLTRB(.left, .top, .right, .bottom)
EndIf
EndWith
EndFunction
''' In Button3 Click Event
Dim fPar AsInteger = Lvfind.LVFindItem.LVFI_PARTIAL
' Clear any selection in the ListView control
' ClearSelection()
' Make an instance of the LVFindItem class
Dim lvf AsNew LVFind.LVFindItem
' Call the LVFnd() sub
' 1st parm is ListView control
' 2nd parm is text to find
' 3rd parm is flag value (see LVFind class for definition)
lvf.LVFnd(ListView1, TextBox5.Text, fPar)
' Focus the ListView control so we can see which item is selected
ListView1.Focus()
Again I can only search the first colum of data.......... need to search the 3rd column actually. Thanks in advance
Dave