Go4Expert (http://www.go4expert.com/)
-   Visual Basic ( VB ) (http://www.go4expert.com/forums/visual-basic/)
-   -   ListView in VB.net (http://www.go4expert.com/forums/listview-in-vbnet-t987/)

khwo 7Jul2006 10:30

ListView in VB.net
Hi all,

I facing a problem with listview now, now I have data in the listview, when I click on the header of the column1, the search key will be point to column1. Mean that user will search what ever data in column1. When user click on the column2 then the search key will point to column2 no longer in column1 at all. For example, I have 3 column in my listview, 1) Employee No, 2) First Name 3) Second Name, when user click on the header of Employee No, user only can search for employee no not for first name and second name, by the way, user click on the header of first name, the user sure only can search for first name, and no more for employee no and also not for second name. Can anyone help me on this? Thanks.

shabbir 7Jul2006 10:41

Re: ListView in VB.net
Just have a variable which denotes the column name to be searched upon and in the header click event set it to appropriate value and when searching use the variable to your advantage.

khwo 17Jul2006 07:47

Re: ListView in VB.net
Hi All,

Iím using the following coding for my searching function at listview, but I facing some problem here, if I use this code I only able to search the item at column 0 for the listview. But for my case, I want to let user click on the header of the column then the user only can key in the data for that column they select, what mean is if user click on the column 0 at the header of the listview then user only can search what ever data appear at the column 0 for the listview. As well for column 1, column 2 for the listview. The following coding only allow me to search the data at column 0 even I use the select case for the column click. What mistake I have made? Can anyone give me some advice on this? Thanks.

This is my coding for the searching function at lisview:-
Code: VB

Private Sub ListView_Master_ColumnClick(ByVal sender As Object, ByVal e As System.Windows.Forms.ColumnClickEventArgs) Handles ListView_Master.ColumnClick

        Dim Search_Code As String
        Dim exactMatch As Boolean
        Dim mySearchText As String

        Select Case e.Column
            Case 0 'column one BOM ID


            Case 1 'column two Cust Part # = BOM


                mySearchText = Trim(InputBox("Please enter your Customer Part #", "Search Product Master Entry Data"))

                'For Each itm As ListViewItem In ListView_Master.Items
                For Each itm As ListViewItem In ListView_Master.Items
                    If exactMatch Then
                        If itm.Text = mySearchText Then
                            ' an exact match was found ...
                        End If
                        mySearchText &= "*"
                        If itm.Text Like mySearchText Then
                            ' a partial match was found ...
                        End If
                    End If

            Case 2 'column three Child Part#A = CodeAChild Part#B = CodeB

            Case 3 'column three Child Part#B = CodeB

        End Select

    End Sub

shabbir 17Jul2006 10:35

Re: ListView in VB.net
Refer to thread ListView in VB.Net.

All times are GMT +5.5. The time now is 04:00.