Question

How can I call a CharAdded event when my scintilla Text window has text added. I have tried adding this:

  Private Sub Scintilla_CharAdded(ByVal sender As System.Object, ByVal e As ScintillaNet.CharAddedEventArgs) Handles Scintilla1.CharAdded
        CType(TabControl1.SelectedTab.Controls.Item(0), Scintilla).AutoComplete.Show()
    End Sub

But it only calls when the Scintilla window is implemented on my form in the design file. However I needed to work when I implement it like this:

Dim TextInput As New Scintilla

So is it possible to call this event when it is not placed directly in my designer?

Thanks.

Was it helpful?

Solution

If you want to use the Handles keyword, you can do so by defining your TextInput as a field of your form (a variable at the form-level, outside of any method). You then need to add the WithEvents modifier to the variable declaration, like this:

Public Class MyForm
    Private WithEvents TextInput As New Scintilla

    Private Sub Scintilla_CharAdded(sender As Object, e As ScintillaNet.CharAddedEventArgs) Handles TextInput.CharAdded
        ' ...
    End Sub
End Class

If you can't define it as a field of your form, then you won't be able to use the Handles keyword. In that case, you'd need to resort to using the AddHandler and RemoveHandler commands to register your event handler with the object.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top