Results 1 to 3 of 3

Thread: regarding more time to load listview items

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2006
    Location
    Aurangabad
    Posts
    25

    regarding more time to load listview items

    i have used listview to select item from it . also i am providing search from text box on key up event in vb6. listview contains approx 36000 item . database is in ms access. it tooks lot of time to display characters and corresponding listview items. pl. help me

    i have used following code
    vb Code:
    1. Private Sub txtItemName_KeyUp(KeyCode As Integer, Shift As Integer)
    2. On Error GoTo Err_Handler
    3.     ListView1.Visible = True
    4.     If (KeyCode <> 37 And KeyCode <> 38 And KeyCode <> 39 And KeyCode <> 40 And KeyCode <> 27 And KeyCode <> 13) Then
    5.         txtItemName.ForeColor = vbBlack
    6.         string1 = Trim(txtItemName.Text) & "%"
    7.         ListView1.Visible = True
    8.         ListView1.FullRowSelect = True
    9.         ListView1.ColumnHeaders.Clear
    10.         ListView1.ListItems.Clear
    11.         ListView1.View = lvwReport
    12.         ListView1.GridLines = True
    13.        
    14.         ListView1.ColumnHeaders.Add , , "Item Name", 3000
    15.         ListView1.ColumnHeaders.Add , , "Pkg.", 1200
    16.         ListView1.ColumnHeaders.Add , , "Mfg.Code", 1000
    17.        
    18.                 Set rs3 = cn.Execute("Select * from M_Itemmaster Where ItemName like '" & string1 & "'")
    19.                 While Not rs3.EOF
    20.                     flgFound = True
    21.                                 If Not IsNull(rs3("ItemName")) Then ItemName = rs3("ItemName")
    22.                                 If Not IsNull(rs3("Packing")) Then Packing = rs3("Packing")
    23.                                 If Not IsNull(rs3("MfgCode")) Then MfgCode = rs3("MfgCode")
    24.                                
    25.                                     Set itmX = ListView1.ListItems.Add(, , CStr(ItemName))
    26.                                     itmX.SubItems(1) = CStr(Packing)
    27.                                     itmX.SubItems(2) = CStr(MfgCode)
    28.                                    
    29.                                 rs3.MoveNext
    30.                 Wend
    31.                 If Not flgFound Then
    32.                 MsgBox "No Record Exists"
    33.                 txtItemName.SetFocus
    34.                 Exit Sub
    35.                 End If
    36.                 rs3.Close
    37.                 Set rs3 = Nothing
    38.                 ListView1.FullRowSelect = True
    39.                 ListView1.Visible = True
    40.            
    41.     ElseIf KeyCode = 40 Then
    42.         If ListView1.Visible = True Then
    43.             ListView1.SetFocus
    44.             Set itmX = ListView1.SelectedItem
    45.  
    46.             lblCompany.Caption = ""
    47.             Set rs = cn.Execute("Select * From CompanyMaster where MfgCode = '" & itmX.SubItems(2) & "'")
    48.             If Not rs.EOF Then
    49.                 lblCompany.Caption = rs("CompanyName")
    50.             End If
    51.             rs.Close
    52.             Set rs = Nothing
    53.             Call AddBatchDetails(itmX)
    54.             ListView1.SetFocus
    55.         End If
    56.     ElseIf KeyCode = 27 Then
    57.             Unload Me
    58. '        ListView1.Visible = False
    59.     End If
    60. Err_Handler:
    61. Exit Sub
    62.     Call ERROR_DISPLAY(Err.Number)
    63. End Sub
    Last edited by Hack; Jun 22nd, 2009 at 06:25 AM. Reason: adding code - adding Highlight Tags

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: regarding more time to load listview items

    Thread moved from the CodeBank forum (which is for you to post your code examples, not questions)

    Manipulating 36000 items in a control (whether a ListView or something else) will always be fairly slow. The chances are that you would get much better speed by re-thinking how this part of the program should be done.

    In addition to that, the code you are using may be slowing things down - but we can't tell, as you haven't shown us the code.

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: regarding more time to load listview items

    No one is going to want to wade through 36,000 items to find one thing.

    You need to seriously filter what is being displayed at anyone given time.

    It looks like you are displaying some kind of items so how about a combo box containing the 26 letters of the alphabet and the listview gets loaded with all items that begin with the selected letter?

    Just a suggestion...but, as si__the_geek said, you do need to rethink how this thing works. If you load all 36,000 items in the listview, then it is going to be slow.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width