1

I am populating a ListBox with the current function:

Public Function fillListBox5(theList As List(Of FARG_Data))
    For Each item In theList
        ListBox5.Items.Add(item.getFargFunction)
    Next
End Function

This works well, but some of the item's FargFunctions are decently long causing portions of the string to be cut off at the end of the ListBox. Is there anyway I can make the text wrap so that none of it is cut off?

Bugs
  • 4,491
  • 9
  • 32
  • 41
Bob
  • 1,344
  • 3
  • 29
  • 63
  • Its not cut off as in truncated, it just isnt showing. If you want it to wrap, you are probably going to have to make it OwnerDraw and paint them yourself. You also do not need to copy the data to the control one by one - just use the List as a DataSource: `ListBox52,DataSource = theList` – Ňɏssa Pøngjǣrdenlarp Apr 27 '17 at 16:12
  • Have you looked at this? http://stackoverflow.com/questions/17613613/winforms-dotnet-listbox-items-to-word-wrap-if-content-string-width-is-bigger-tha – Prescott Chartier Apr 27 '17 at 16:21
  • @PrescottChartier Thanks for pointing me to that question, weird title... must have been why I couldn't find it. – Bob Apr 27 '17 at 16:30

2 Answers2

1

Set the ListBox.HorizontalScrollbar property to True. This can either be done within the designer or programmatically:

ListBox5.HorizontalScrollbar = True

This will give the user the ability to scroll and view all the text:

enter image description here

enter image description here

Bugs
  • 4,491
  • 9
  • 32
  • 41
-1

Or you can set the css style overflow: auto;

select {
    overflow: auto;
}
Ryan Huang
  • 728
  • 6
  • 7