Quantcast
Viewing all articles
Browse latest Browse all 27412

ListBox takes too long time to show

I have a Form2 with ListBox, i fill the listbox with the content of big size text file, this isn't the problem but the problem is occur when showing Form2, the form take long time to show.

Code:

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim s As Single = Microsoft.VisualBasic.Timer
        Form2.ListBox1.Items.AddRange(IO.File.ReadAllLines("C:\Test.txt"))' this file contains about 500000 lines
        MsgBox(Microsoft.VisualBasic.Timer - s)' the time is about 0.03 seconds
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
      Dim s As Single = Microsoft.VisualBasic.Timer
      Form2.Show()
      MsgBox(Microsoft.VisualBasic.Timer - s)' the time is about 5 seconds
    End Sub

I tried ListView control, but it is act the same.

How can i fix this?

Viewing all articles
Browse latest Browse all 27412

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>