cardinal |
Дата 31.5.2005, 16:07 (ссылка)
  |   (нет голосов)
Загрузка ...
|
|
|

Инженер
   
Профиль
Группа: Экс. модератор
Сообщений: 6003
Регистрация: 26.3.2002
Где: Германия
Репутация: 19 Всего: 99
|
ListBox: Код | Declare Function SendMessage Lib "User32" Alias "SendMessageA" _ (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const LB_FINDSTRINGEXACT = &H1A2
RetValue = SendMessage(lstList.hWnd, LB_FINDSTRINGEXACT, -1, ByVal FindString)
|
ListView: Код | Public Function ListViewDoSearch(lstListName As ListView, strStringToFind As String, _ Optional blnWholeWordOnly As Boolean, Optional blnCaseSensitive As Boolean) As Integer Dim lngIndex As Long Dim lngIndexSub As Long Dim strCurrItem As String If blnCaseSensitive = True Then strStringToFind = UCase(strStringToFind) ListViewDoSearch = 0 If lstListName.ListItems.Count < 1 Then Exit Function If lstListName.SelectedItem.Index = -1 Then lstListName.SelectedItem.Index = 1 For lngIndex = lstListName.SelectedItem.Index - -1 To lstListName.ListItems.Count If blnCaseSensitive = True Then strCurrItem = UCase(lstListName.ListItems.Item(lngIndex).Text) Else strCurrItem = lstListName.ListItems.Item(lngIndex).Text End If If blnWholeWordOnly = True Then If strCurrItem = strStringToFind Then GoTo Conclude Else If InStr(strCurrItem, strStringToFind) > 0 Then GoTo Conclude End If If lstListName.ColumnHeaders.Count > 1 Then For lngIndexSub = 1 To lstListName.ColumnHeaders.Count - 1 If blnCaseSensitive = True Then strCurrItem = UCase(lstListName.ListItems.Item(lngIndex).SubItems(lngIndexSub)) Else strCurrItem = lstListName.ListItems.Item(lngIndex).SubItems(lngIndexSub) End If If blnWholeWordOnly = True Then If strCurrItem = strStringToFind Then GoTo Conclude Else If InStr(strCurrItem, strStringToFind) > 0 Then GoTo Conclude End If Next lngIndexSub End If Next lngIndex Exit Function Conclude: ListViewDoSearch = lngIndex lstListName.ListItems.Item(lngIndex).EnsureVisible lstListName.ListItems.Item(lngIndex).Selected = True End Function
|
|
|
|
|