The line of code below adds each line too each index of the list Box.
ListBox1.Items.AddRange(CType(TabControl1.SelectedTab.Controls.Item(0), RichTextBox).Lines)
This works however, if I wish to perform the same function as the line below but with the ScintillaNet DLL. I have tried the same thing with the use of the dll but it's not quite the same. Here was the code I tested:
ListBox1.Items.AddRange(CType(TabControl1.SelectedTab.Controls.Item(0), ScintillaNet.Scintilla).Lines)
I am sorry I am asking such a silly question but I am a noob at the ScintillaNet DLL.
Any help will be appreciated.
The
ListBox.Items.AddRange
method only accepts an array ofObject
. TheScintillaNet.Scintilla.Lines
property is aScintillaNet.LinesCollection
object, not an array. As such, you cannot pass it to theListBox.Items.AddRange
method.The
RichTextBox.Lines
property, on the other hand, is an array ofString
, so that can be passed to theListBox.Items.AddRange
method.Unfortunately, there is no easy way to convert from a
ScintillaNet.LinesCollection
object to an array. You could use it'sCopyTo
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:Notice that I am adding
i.Text
to theListBox
rather than justi
. As Steve astutely pointed out in the comments below, theLineCollection
contains a list ofLine
objects. TheToString
method on theLine
class simply outputs the line index rather than the text from that line.