ListView control can only display 259 characters per column

Article translations Article translations
Article ID: 321104 - View products that this article applies to.
This article was previously published under Q321104
Expand all | Collapse all

On This Page


When you add long strings to a ListView control, all of the string is added to the items collection, but the control can only display the first 259 characters of each item.


To display the full text of an item in the ListView control, you can populate a TextBox control with the selected value. For example, the following code populates a TextBox (TextBox1) with the text from the first item that is selected from the ListBox control (ListBox1):
   Private Sub ListView1_SelectedIndexChanged(ByVal sender _
         As Object, ByVal e As System.EventArgs) _
         Handles ListView1.SelectedIndexChanged
      Me.TextBox1.Text = ListView1.SelectedItems(0).Text
   End Sub


This behavior is by design.


Steps to Reproduce the Behavior

  1. Follow these steps to create a new Visual Basic Windows Application:
    1. Start Microsoft Visual Studio .NET or Microsoft Visual Basic 2005.
    2. On the File menu, point to New, and then click Project.
    3. In the New Project dialog box, click Visual Basic Projects under Project Types, and then click Windows Application under Templates. By default, Form1 is created.

      Note In Visual Studio 2005, click Visual Basic under Project Types.
  2. Drag a ListView control from the Windows Forms portion of the toolbox to Form1. By default, the control is named ListView1.
  3. Add the following code to the Load event of Form1:
       Dim MyColumn As ColumnHeader
       Dim MyListViewItem As ListViewItem
       Dim strSample As String
       strSample = "This is a long paragraph to demonstrate" _
          & " the 259 character limitation of the ListView" _
          & " control. Although the string is stored in its" _
          & " entirety, the ListView control can only display" _
          & " the first two hundred and fifty nine characters" _
          & " of the string value. The ListBox control in" _
          & " Visual Basic .NET offers an alternative in that" _
          & " it now supports a horizontal scroll bar so that" _
          & " the user can view all of the string when necessary."
       ' Create a column header for the data.
       MyColumn = New ColumnHeader()
       MyColumn.Text = "Sample"
       ' Create sample ListView data.
       MyListViewItem = New ListViewItem(strSample)
       ' Set view of ListView to Details.
       Me.ListView1.View = View.Details
  4. Drag a Button control from the Windows Forms portion of the toolbox to Form1. By default, the control is named Button1.
  5. Add the following code to the Click event of Button1:
       Dim strText As String
       strText = ListView1.Items(0).Text
       MessageBox.Show(Len(strText) & ": " & strText)
  6. Save the project.
  7. On the Debug menu, click Start.
  8. When the form appears, resize the ListView column header as far as possible. Notice that the text stops at a point after "The Lis" (of the sentence that begins "The ListBox control") even though the column is wider than the text that is displayed.
  9. Click Button1, and notice that the MessageBox returns the string length of 407 followed by the complete text.


Article ID: 321104 - Last Review: February 12, 2007 - Revision: 2.1
  • Microsoft Visual Basic 2005 Express Edition
  • Microsoft Visual Basic .NET 2003 Standard Edition
  • Microsoft Visual Basic .NET 2002 Standard Edition
kbvs2005swept kbvs2005applies kbctrl kblistview kbprb KB321104

Give Feedback


Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from