OnSelectionChanged\OnTextChanged similar events

Topics: Developer Forum, User Forum
Mar 5, 2008 at 12:06 AM
Hi All,

I search ScintillaNET for event similar to OnSelectionChanged\OnTextChanged of RichTextBox (and looked at Scintilla) but can't find something that look similar, any hints?

Mar 5, 2008 at 1:18 AM
ScintillaNET 2.0 has the following events you might be interested in.
Mar 13, 2008 at 2:51 PM
In my very limited experience the TextChanged event does not seem to work... it never seems to fire. It would be nice to have it working, in order to allow data-binding to the Text property to work correctly. Has anyone been able to use it successfully?
Jul 25, 2008 at 2:42 PM
Yeah TextChanged isn't very reliable and it may never be because Scintilla doesn't really expose a notification specifically for Text Changed. I think at one point I was trying to be clever and listen to the other notifications and make a best guess as to when to fire the event, but I think I gave up on that.

DocumentChange is probably the event you actually want.

Also DataBinding to Text doesn't work, I tried in one of my projects and found it's just easier to set the values manually on focus/validating events.
Sep 25, 2010 at 8:27 AM

On my search for my TextChanged problems I came across this post. TextChanged works nicely after propper installation. Initialize the TextChanged after the form is loaded. For my taste DocumentChange fires too often.

Here the code which works for me on Weifen's DockContent control:

public partial class DockContentTextEditor : WeifenLuo.WinFormsUI.Docking.DockContent
	ScintillaNet.Scintilla textEditor;

	public DockContentTextEditor()
	/// <summary>
	/// Handles the Load event and implements the Application.Idle event handler.
    /// </summary>
    protected override void OnLoad(EventArgs args)
         Application.Idle += new EventHandler(OnFormLoaded);
    /// <summary>
    /// Handles the FormLoaded event.
    /// </summary>
    private void OnFormLoaded(object sender, EventArgs args)
        Application.Idle -= new EventHandler(OnFormLoaded);

        // implementation of TextChanged must occur after FormLoaded
        // otherwise we receive an TextChanged event during load which
        // we cannot suppress.
        textEditor.TextChanged += new EventHandler<EventArgs>(textEditor_TextChanged);
    /// <summary>
    /// TextEditor TextChanged event handler.
    /// Note: event handler must be initiated after form loaded.
    /// </summary>
    void textEditor_TextChanged(object sender, EventArgs e)
        // DO SOMETHING