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.AddRangemethod only accepts an array ofObject. TheScintillaNet.Scintilla.Linesproperty is aScintillaNet.LinesCollectionobject, not an array. As such, you cannot pass it to theListBox.Items.AddRangemethod.The
RichTextBox.Linesproperty, on the other hand, is an array ofString, so that can be passed to theListBox.Items.AddRangemethod.Unfortunately, there is no easy way to convert from a
ScintillaNet.LinesCollectionobject to an array. You could use it'sCopyTomethod 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.Textto theListBoxrather than justi. As Steve astutely pointed out in the comments below, theLineCollectioncontains a list ofLineobjects. TheToStringmethod on theLineclass simply outputs the line index rather than the text from that line.