Hello everyone, I need small help..
So I got working text file loading to listview, but if file is to big it get whole app stuck untill it load it out... So my question is, is it possible loading with background worker and progress bar?

Here is my current source:

            Dim asd As New OpenFileDialog
            asd.Title = "Select your combo"
            asd.Filter = ("Text Files|*.txt")
            Dim MyStream As New IO.StreamReader(asd.FileName)
            Dim strTemp() As String
            Do While MyStream.Peek <> -1 
                Dim LVItem As New ListViewItem
                strTemp = MyStream.ReadLine.Split(":"c)
                LVItem.Text = strTemp(0).ToString
                If strTemp.Length > 2 Then LVItem.SubItems.Add(strTemp(2).ToString)

        Catch ex As Exception
            MessageBox.Show("Error reading file." & ex.Message)
        End Try

Also is it possible somehow to remove whole row in listview if some column is emtpy? So like on button click it automatically checks whole list and remove all empty rows ?

Yes. It is possible to do that. You will need to update the ListView through a Delegate. There is a tutorial on doing that here. I don't think it uses a progress bar but once you get the first part working we can deal with the progress bar later. One thing that you might try before going the backiground thread route is to disable updates while the ListView is being loaded. If you don't then the ListView will refresh on every addition. That can really slow things down. You can do that by


'loop to load ListView

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.