本帖最后由 ceoguang 于 2011-2-27 00:31 编辑
本来查找ListView关键字就是完全匹配的,具体请查看LVM_GETITEMTEXT 消息
_GUICtrlListView_FindInText只是一个封装好的UDF,而不是内置函数.
原理是枚举所有Item,通过发送LVM_GETITEMTEXT消息来取字符.
Func _GUICtrlListView_FindInText($hWnd, $sText, $iStart = -1, $fWrapOK = True, $fReverse = False)
Local $iCount = _GUICtrlListView_GetItemCount($hWnd)
Local $iColumns = _GUICtrlListView_GetColumnCount($hWnd)
If $iColumns = 0 Then $iColumns = 1
If $fReverse And $iStart = -1 Then Return -1
Local $sList
If $fReverse Then
For $iI = $iStart - 1 To 0 Step -1
For $iJ = 0 To $iColumns - 1
$sList = _GUICtrlListView_GetItemText($hWnd, $iI, $iJ)
If StringInStr($sList, $sText) Then Return $iI
Next
Next
Else
For $iI = $iStart + 1 To $iCount - 1
For $iJ = 0 To $iColumns - 1
$sList = _GUICtrlListView_GetItemText($hWnd, $iI, $iJ)
If StringInStr($sList, $sText) Then Return $iI
Next
Next
EndIf
If (($iStart = -1) Or Not $fWrapOK) And Not $fReverse Then Return -1
If $fReverse And $fWrapOK Then
For $iI = $iCount - 1 To $iStart + 1 Step -1
For $iJ = 0 To $iColumns - 1
$sList = _GUICtrlListView_GetItemText($hWnd, $iI, $iJ)
If StringInStr($sList, $sText) Then Return $iI
Next
Next
Else
For $iI = 0 To $iStart - 1
For $iJ = 0 To $iColumns - 1
$sList = _GUICtrlListView_GetItemText($hWnd, $iI, $iJ)
If StringInStr($sList, $sText) Then Return $iI
Next
Next
EndIf
Return -1
EndFunc ;==>_GUICtrlListView_FindInText
看到没有?
将里面的StringInStr($sList, $sText)改为$sList==$sText就能达到了你的要求了. |