This doesn't seem to work when looping through a DocumentLineCollection and changing each line, or at least the scroll bar still moves and you end up and the end of the document. Probably need to turn off some kind of keep current row visible state but can't find that, I'm changes a bunch of lines and SuspendPainting() doesn't stop it from scrolling to the bottom, hmmm ...
Hi Mike,
You can pass DocumentModificationFlags.RetainSelection to the document modification overloads to keep the caret from moving to the end of the modification.
I saw that you can use that on Document.ReplaceText() but this is my code
private void ReplaceBlankLinesWithDot(DocumentLineCollection lines)
{
foreach(DocumentLine line in lines)
{
string tmp = line.Text;
tmp = tmp.Replace("\t", "");
tmp = tmp.Trim();
if (tmp.Length == 0)
{
line.Text = ".";
}
}
}
So I'm changing each line (possibly) and don't really see how I can use that. I'm think I'm just stuck with it scrolling.
[Modified 11 years ago]
You shouldn't edit the strings directly. You should work with the methods the Document offers instead.
foreach(DocumentLine line in lines)
{
Document.ReplaceText(DocumentModificationType.Custom, line.TextRange, newText, DocumentModificationOptions.RetainSelection);
}
Worked perfectly thanks, sure made it work faster too, again, thanx ...
Please log in to a validated account to post comments.