View Single Post
  #27  
Old 07-01-2008, 10:26 AM
nosfentora
Discordant
 
Join Date: Oct 2004
Location: In a house
Posts: 387
Default

GeorgeS,

I have the all 20k spells loading and displaying in a listview in +/-12s on a P4 3GHz machine. Seems to use about 15mb of memory

Probably not the most efficient way to do things, but it's fairly quick (depending on your point of view). It can be easily modified to allow searching by partial name too.

It could be done at load time so that there's no further waiting later on - or even threaded load so it's kinda invisible, and then you just show / hide the listview as need be.

Code:
    If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            Dim r As New IO.StreamReader(OpenFileDialog1.FileName)
            ListView1.BeginUpdate()
            While Not r.EndOfStream
                Dim s() As String = Split(r.ReadLine, "^")
                Dim lv As New ListViewItem(s(0))
                lv.SubItems.Add(New ListViewItem.ListViewSubItem(lv, s(1)))
                ListView1.Items.Add(lv)
                System.Windows.Forms.Application.DoEvents()
            End While
            ListView1.EndUpdate()
            r.Close()
            r.Dispose()
            r = Nothing
            GC.Collect()
        End If
Reply With Quote