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:

Try
            Dim asd As New OpenFileDialog
            asd.Title = "Select your combo"
            asd.Filter = ("Text Files|*.txt")
            asd.ShowDialog()
            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
                ListView1.Items.Add(LVItem)
                LVItem.SubItems.Add(strTemp(1).ToString)
                If strTemp.Length > 2 Then LVItem.SubItems.Add(strTemp(2).ToString)
            Loop

            MyStream.Close() 
        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

ListView1.SuspendLayout()

'loop to load ListView

ListView1.ResumeLayout()
This article has been dead for over six months. Start a new discussion instead.