|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
IntroductionDo you want to find an BackgroundVB 6 supports a For Each itm As ListViewItem In ListView1.Items
If exactMatch Then
If itm.Text = mySearchText Then
' an exact match was found ...
End If
Else
mySearchText &= "*"
If itm.Text Like mySearchText Then
' a partial match was found ...
End If
End If
Next
where myRect = ListView1.Items(0).GetBounds(ItemBoundsPortion.Entire)
Unfortunately, myRect = ListView1.Items(0).SubItems(1).GetBounds(ItemBoundsPortion.Entire)
produces the following error: 'GetBounds' is not a member of 'System.Windows.Forms.ListViewItem.ListViewSubItem'.
Using the codeTo use the To search for a string in the Dim fPar As Integer = LVFind.LVFindItem.LVFI_PARTIAL
Dim mySearchString As String = "findme"
...
Sub Find()
FindIt(mySearchString, fPar)
End Sub
...
' Search for SearchString in ListView1 Items
Private Sub FindIt(ByVal SearchString As String, _
Optional ByVal flag As Integer = LVFind.LVFindItem.LVFI_PARTIAL)
' Make an instance of the LVFindItem class
Dim lvf As New LVFind.LVFindItem
' Call the LVFnd() sub
' 1st parm is ListView control
' 2nd parm is text to find
' 3rd parm (optional) is flag value (see LVFindItem class for definition)
lvf.LVFnd(ListView1, SearchString, flag)
' Focus the ListView control so we can see which item is selected
ListView1.Focus()
End Sub
To get the bounding rectangle of a Dim itmIdx As Integer = 1 ' The index of the Item in the Items collection
Dim colNum As Integer = 2 ' The column of the Item or SubItem
Dim myRect As Rectangle ' Holds the return value from Locate()
...
Sub GetRect()
myRect = Locate(itmIdx, colNum)
End Sub
...
'Get bounding rectangle of Item itm, Column col
Private Function Locate(ByVal itm As Integer, ByVal col As Integer) As Rectangle
' Make an instance of the LVFindItem class
Dim lvf As New LVFind.LVFindItem
' A new Rectangle to hold the return value from GetSubItemRect
Dim rect As New Rectangle
' Call the GetSubItemRect() function
' 1st parm is ListView control
' 2nd parm is index of Item to find
' 3rd parm is column of SubItem to find
' 4th parm (optional) is flag value (see LVFindItem class for definition)
rect = lvf.GetSubItemRect(ListView1, itm, col, LVFind.LVFindItem.LVIR_LABEL)
Return rect
End Function
Points of InterestInterestingly, on MSDN, under the definition of the History23rd Jan 2005 - First release.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||