<bdo id='YaV8t'></bdo><ul id='YaV8t'></ul>
  • <i id='YaV8t'><tr id='YaV8t'><dt id='YaV8t'><q id='YaV8t'><span id='YaV8t'><b id='YaV8t'><form id='YaV8t'><ins id='YaV8t'></ins><ul id='YaV8t'></ul><sub id='YaV8t'></sub></form><legend id='YaV8t'></legend><bdo id='YaV8t'><pre id='YaV8t'><center id='YaV8t'></center></pre></bdo></b><th id='YaV8t'></th></span></q></dt></tr></i><div id='YaV8t'><tfoot id='YaV8t'></tfoot><dl id='YaV8t'><fieldset id='YaV8t'></fieldset></dl></div>

  • <legend id='YaV8t'><style id='YaV8t'><dir id='YaV8t'><q id='YaV8t'></q></dir></style></legend>

    <small id='YaV8t'></small><noframes id='YaV8t'>

    <tfoot id='YaV8t'></tfoot>

      1. TextBox.AppendText() 不自动滚动

        TextBox.AppendText() not autoscrolling(TextBox.AppendText() 不自动滚动)
          <tfoot id='YkoUX'></tfoot>

              <tbody id='YkoUX'></tbody>
          1. <small id='YkoUX'></small><noframes id='YkoUX'>

            <legend id='YkoUX'><style id='YkoUX'><dir id='YkoUX'><q id='YkoUX'></q></dir></style></legend>
              <bdo id='YkoUX'></bdo><ul id='YkoUX'></ul>
              • <i id='YkoUX'><tr id='YkoUX'><dt id='YkoUX'><q id='YkoUX'><span id='YkoUX'><b id='YkoUX'><form id='YkoUX'><ins id='YkoUX'></ins><ul id='YkoUX'></ul><sub id='YkoUX'></sub></form><legend id='YkoUX'></legend><bdo id='YkoUX'><pre id='YkoUX'><center id='YkoUX'></center></pre></bdo></b><th id='YkoUX'></th></span></q></dt></tr></i><div id='YkoUX'><tfoot id='YkoUX'></tfoot><dl id='YkoUX'><fieldset id='YkoUX'></fieldset></dl></div>

                1. 本文介绍了TextBox.AppendText() 不自动滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我尝试了以下方法让我的文本框文本自动滚动:

                  I tried the following to get my Textbox text to automatically scroll:

                  我使用的步骤非常简单:

                  The steps I am using are pretty trivial:

                  1. 将文本框拖到表单上.
                  2. 将文本框更改为多行.
                  3. 添加垂直滚动.
                  4. 使用 AppendText() 将文本添加到文本框.

                  尽管尝试了此处提到的解决方案,但文本不会自动滚动:

                  The text does not automatically scroll, despite trying to solutions mentioned here:

                  我该怎么做自动滚动到多行文本框的底部?

                  这是什么原因造成的,我该如何解决?

                  What could cause this and how do I fix it?

                  更新:如果我创建一个按钮并使用它来调用 AppendText() 我会得到所需的行为.但是,如果我尝试从表单的构造函数或 Load() 事件调用 AppendText,那么我会得到附加的文本,但 TextBox 不会滚动.这不是一个重复的问题,因为我过去没有看到有人发布过这个问题.

                  UPDATE: If I create a button and use it to call AppendText() I get the desired behavior. However, if I try to call AppendText from the form's constructor or Load() event then I get the appended text but the TextBox does not scroll. This is NOT a duplicate question as I haven't seen anyone post this problem in the past.

                  推荐答案

                  由于表单在构造函数和加载事件期间还没有完全准备好,我不得不使用一个任务让它在它准备好后滚动:

                  Since the form isn't quite ready during the constructor and load event, I had to use a task to get it to scroll after it becomes ready:

                  p>

                  这里是被调用的方法:

                  Here is the method that gets invoked:

                  void scroll()
                  {
                      this.Invoke(new MethodInvoker(delegate()
                          {
                              textBox1.SelectionStart = textBox1.Text.Length;
                              textBox1.ScrollToCaret();
                          }));
                  }
                  

                  它通过放置在加载事件中的这个任务被调用:

                  It gets invoked via this task placed in the load event:

                  Task task1 = new Task(new Action(scroll));
                              task1.Start();
                  

                  这篇关于TextBox.AppendText() 不自动滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to keep the Text of a Read only TextBox after PostBack()?(PostBack()之后如何保留只读文本框的文本?)
                  Winforms Textbox - Using Ctrl-Backspace to Delete Whole Word(Winforms 文本框 - 使用 Ctrl-Backspace 删除整个单词)
                  C# - Add button click events using code(C# - 使用代码添加按钮单击事件)
                  Multi-color TextBox C#(多色文本框 C#)
                  How can i set the caret position to a specific index in passwordbox in WPF(如何将插入符号位置设置为 WPF 密码框中的特定索引)
                  C# Numeric Only TextBox Control(C# 纯数字文本框控件)

                      <i id='BosGU'><tr id='BosGU'><dt id='BosGU'><q id='BosGU'><span id='BosGU'><b id='BosGU'><form id='BosGU'><ins id='BosGU'></ins><ul id='BosGU'></ul><sub id='BosGU'></sub></form><legend id='BosGU'></legend><bdo id='BosGU'><pre id='BosGU'><center id='BosGU'></center></pre></bdo></b><th id='BosGU'></th></span></q></dt></tr></i><div id='BosGU'><tfoot id='BosGU'></tfoot><dl id='BosGU'><fieldset id='BosGU'></fieldset></dl></div>

                    • <small id='BosGU'></small><noframes id='BosGU'>

                          <tbody id='BosGU'></tbody>
                          <bdo id='BosGU'></bdo><ul id='BosGU'></ul>
                          <legend id='BosGU'><style id='BosGU'><dir id='BosGU'><q id='BosGU'></q></dir></style></legend>
                          • <tfoot id='BosGU'></tfoot>