The ListBox.Items.AddRange
method only accepts an array of Object
. The ScintillaNet.Scintilla.Lines
property is a ScintillaNet.LinesCollection
object, not an array. As such, you cannot pass it to the ListBox.Items.AddRange
method.
The RichTextBox.Lines
property, on the other hand, is an array of String
, so that can be passed to the ListBox.Items.AddRange
method.
Unfortunately, there is no easy way to convert from a ScintillaNet.LinesCollection
object to an array. You could use it's CopyTo
method to copy the collection to an array, but it's probably easier and more efficient to just loop through the collection and add each one individually, like this:
For Each i As Line In CType(TabControl1.SelectedTab.Controls.Item(0), ScintillaNet.Scintilla).Lines
ListBox1.Items.Add(i.Text)
Next
Notice that I am adding i.Text
to the ListBox
rather than just i
. As Steve astutely pointed out in the comments below, the LineCollection
contains a list of Line
objects. The ToString
method on the Line
class simply outputs the line index rather than the text from that line.