Q&A

  • ListView 검색에 대한 문의 입니다. ^^
TEdit 박스 TListView

TEdit 박스 change 이벤트 발생시
'가' 을 입력 했을 때
해당 리스트 뷰 가 컬럼의 Row select  시키고 싶은데요..

잘 안되네요... vb로는

Private Sub txtSearch_Change()
    Dim strFindItem As String
    Dim itmFound    As ListItem
    Dim itmX        As ListItem
    Dim i           As Long
    Dim lngColNo    As Long
        
    strFindItem = Trim(txtSearch.Text)
    
    With lvwCodeList
        For i = 1 To .ColumnHeaders.Count
            If InStr(.ColumnHeaders(i).Text, "▲") > 0 Or InStr(.ColumnHeaders(i).Text, "▼") > 0 Then
                lngColNo = i
                Exit For
            End If
        Next
        
        If lngColNo = 1 Then
            For i = 1 To .ListItems.Count
                Set itmX = .ListItems(i)
                If UCase(itmX.Text) Like UCase(strFindItem & "*") Then
                    itmX.Selected = True
                    itmX.EnsureVisible
                    Exit For
                End If
            Next
        Else
            For i = 1 To .ListItems.Count
                Set itmX = .ListItems(i)
                If (UCase(itmX.SubItems(lngColNo - 1)) Like (UCase(strFindItem & "*"))) Then
                    itmX.Selected = True
                    itmX.EnsureVisible
                    Exit For
                End If
            Next
        End If
    End With
End Sub
하면
0  COMMENTS