【问题标题】:How to make autoscroll multiline TextBox in WinForms? [duplicate]如何在 WinForms 中制作自动滚动多行文本框? [复制]
【发布时间】:2012-11-10 09:52:53
【问题描述】:

可能重复:
How do I automatically scroll to the bottom of a multiline text box?

我使用多行 TextBox 在新行中输出一些来自 BackgroundWorker 的信息。

我可以让它在每次有新行到达时滚动到最底部吗?

默认情况下,它似乎正好相反 - 每次有新行到达并更改 Text 属性时,它都会滚动到第一行。

【问题讨论】:

    标签: c# .net winforms textbox


    【解决方案1】:

    设置TextBox属性:

    Multiline = True;
    ScrollBars = Both;
    

    TextChanged 事件上自动滚动:

    textBox1.SelectionStart = textBox1.Text.Length;
    textBox1.ScrollToCaret();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-09-04
      • 2012-02-13
      • 1970-01-01
      • 2011-06-05
      • 2021-09-02
      • 2021-10-03
      • 2010-10-28
      • 1970-01-01
      相关资源
      最近更新 更多