Kir*_*web 7 .net c# winforms scintillanet
我在我的 C# Winforms 应用程序中使用 ScintillaNET 控件。我正在尝试实现一个自动标记功能,该功能将在之前自动完成标记,例如,当用户键入时<html>
,自动完成功能将触发并插入</html>
。
我正在CharAdded
为此实现使用 ScintillaNET函数:
if (caretPos != 0)
{
//If the characters before the caret are "ml>" (last three chars from "<html>")
if (TextArea.Text[caretPos - 1] == '>' && TextArea.Text[caretPos - 2] == 'l' && TextArea.Text[caretPos - 3] == 'm')
{
TextArea.Text = TextArea.Text.Insert(caretPos, "</html>");
TextArea.SelectionStart = caretPos + 0;
TextArea.Selections.First();
TextArea.ScrollCaret();
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,Scintilla 控件一直向上或向下滚动。我认为该ScrollCaret()
功能会起作用,但它一直在发生。有任何想法吗?
小智 5
我也一直在努力解决这个问题。以为是bug。甚至 Github 问题页面上给出的解决方案也无济于事。但后来我发现,如果您使用以下方法插入文本:
TextArea.Text = TextArea.Text.Insert(caretPos, "");
Run Code Online (Sandbox Code Playgroud)
那么这本身就是问题所在。ScintillaNET 已经有一个用于Text.Insert
. 使用InsertText
将阻止控件滚动。
发现问题也发here
归档时间: |
|
查看次数: |
186 次 |
最近记录: |