を使用する場合、またはテキストボックスにテキストを追加するためにSystem.Windows.Forms.RichTextBox
使用できるようです。textbox.AppendText()
textbox.Text = ""
AppendText
一番下までスクロールし、テキストを直接追加してもスクロールしませんが、ユーザーがテキストボックスにフォーカスがあると一番上にジャンプします。
これが私の機能です:
// 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
また、うまく機能しなかったスクロール機能をインポートしてオーバーライドしようとしました。
テキストボックスのスクロールを完全に停止する方法を知っている人はいますか?
一番上にも、一番下にも、そしてもちろん現在の選択にも移動するべきではなく、現在の場所にとどまるべきです。