Example. I have 12 lines in my TXT. When I Upload it into listbox. The listbox force the lines tobe 10 lines.
Anyone can teach me how to limit lines on listbox.
Any help would be greatly appreciate. Thank you~

A listbox can hold any number of lines. If you mean that it limits the number of visible lines, you can change that by changing the Height property. If you do

ListBox1.Height = ListBox1.ItemHeight * (1 + ListBox1.Items.Count)

then, assuming the form is big enough, the listbox will display all items without requiring a scrollbar.

Thankyou for your post, but I mean when I have 12 lines in my TXT. When I Upload it into listbox. The listbox force the lines tobe 10 lines, so the listbox will be delete the 11 and 12 line

Please post your code. A snapshot of the textbox would also help.

Maybe the lines in your textbox are wrapped? Make your listbox wider and see if you have all the txt there.

Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       If String.IsNullOrEmpty("D:\email1.txt") Then
          Exit Sub
       End If
           Dim lines() As String = IO.File.ReadAllLines("D:\email1.txt")
           ListBox1.Items.AddRange(lines)
           ListBox1.SelectedIndex = 0
        End Sub
Private Function lines() As String
  Throw New NotImplementedException
End Function

Using LINQ you can just do:

ListBox1.Items.AddRange(lines.Take(10))

You'll need:

Imports System.Linq
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.