I search for a property in the editor to disable the refresh of the selectedview when I change the document.
The problem is: After changing the document, the selectedview scrolls automatically to the changed line.
Please help.
Thank you in advance.
I search for a property in the editor to disable the refresh of the selectedview when I change the document.
The problem is: After changing the document, the selectedview scrolls automatically to the changed line.
Please help.
Thank you in advance.
You can use SuspendPainting() to supsend GUI updates and SelectedView.Selection.SuspendEvents() to suspend selection changed events.
However don't forget to resume the painting/events. I've made myself some helper classes and wrap the calls with a using, so the dispose is called even if there is an exception.
Keep in mind that the selection events are only delayed, not ignored. You probably want to supsend the painting, then do your work, reset the selection and resume painting (in that order).
// Note: This class can only delay the selection changed events, not suppress them
public class SuspendSelectionEvents : IDisposable
{
private bool mIsDisposed = false;
private SyntaxEditor mEditor;
public SuspendSelectionEvents(SyntaxEditor editor)
{
mEditor = editor;
if ((null != mEditor) && (!mEditor.IsDisposed) && (null != mEditor.SelectedView))
{
mEditor.SelectedView.Selection.SuspendEvents();
}
}
~SuspendSelectionEvents()
{
Debug.Assert(mIsDisposed, "dispose object with using section");
Dispose();
}
#region IDisposable Members
public void Dispose()
{
if (!mIsDisposed)
{
mIsDisposed = true;
if ((null != mEditor) && (!mEditor.IsDisposed) && (null != mEditor.SelectedView))
{
mEditor.SelectedView.Selection.ResumeEvents();
}
}
}
#endregion IDisposable Members
}
public class SuspendPainting : IDisposable
{
private bool mIsDisposed = false;
private SyntaxEditor mEditor;
public SuspendPainting(SyntaxEditor editor)
{
mEditor = editor;
if ((null != mEditor) && (!mEditor.IsDisposed))
{
mEditor.SuspendPainting();
}
}
~SuspendPainting()
{
Debug.Assert(mIsDisposed, "dispose object with using section");
Dispose();
}
#region IDisposable Members
public void Dispose()
{
if (!mIsDisposed)
{
mIsDisposed = true;
if ((null != mEditor) && (!mEditor.IsDisposed))
{
mEditor.ResumePainting();
}
}
}
#endregion IDisposable Members
}[Modified 13 years ago]
Hi Tanja,
In your text change you should specify the DocumentModificationOptions.RetainSelection flag. I think that's what you're looking for.
Thanks for your help. That's what i was looking for. :-)
Please log in to a validated account to post comments.