似乎当使用一个时,你可以使用或向文本框中添加文本。
会滚动到底部,直接添加文本不会滚动,但当用户将文本框聚焦时,会跳转到顶部。
下面是我的函数:
下面是我的函数:
// Function to add a line to the textbox that gets called each time I want to add something
// console = textbox
public void addLine(String line)
{
// Invoking since this function gets accessed by another thread
console.Invoke((MethodInvoker)delegate
{
// Check if user wants the textbox to scroll
if (Settings.Default.enableScrolling)
{
// Only normal inserting into textbox here with AppendText()
}
else
{
// This is the part that doesn't work
// When adding text directly like this the textbox will jump to the top if the textbox is focused, which is pretty annoying
Console.WriteLine(line);
console.Text += "\r\n" + line;
}
});
}
我还尝试了导入user32.dll
并覆盖滚动函数,但效果不太好。
有人知道如何彻底停止文本框的滚动吗?
它不应该滚动到顶部,也不应该滚动到底部,当然也不应该滚动到当前选择位置,而是应该保持当前位置不变。