<tfoot id='HFRpw'></tfoot>
      <bdo id='HFRpw'></bdo><ul id='HFRpw'></ul>
    <legend id='HFRpw'><style id='HFRpw'><dir id='HFRpw'><q id='HFRpw'></q></dir></style></legend>

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

  • <i id='HFRpw'><tr id='HFRpw'><dt id='HFRpw'><q id='HFRpw'><span id='HFRpw'><b id='HFRpw'><form id='HFRpw'><ins id='HFRpw'></ins><ul id='HFRpw'></ul><sub id='HFRpw'></sub></form><legend id='HFRpw'></legend><bdo id='HFRpw'><pre id='HFRpw'><center id='HFRpw'></center></pre></bdo></b><th id='HFRpw'></th></span></q></dt></tr></i><div id='HFRpw'><tfoot id='HFRpw'></tfoot><dl id='HFRpw'><fieldset id='HFRpw'></fieldset></dl></div>
      1. 如何使用 C# 滚动到 WinForms TextBox 中的指定行?

        How can I scroll to a specified line in a WinForms TextBox using C#?(如何使用 C# 滚动到 WinForms TextBox 中的指定行?)
        <tfoot id='YLCEe'></tfoot>

      2. <small id='YLCEe'></small><noframes id='YLCEe'>

          <i id='YLCEe'><tr id='YLCEe'><dt id='YLCEe'><q id='YLCEe'><span id='YLCEe'><b id='YLCEe'><form id='YLCEe'><ins id='YLCEe'></ins><ul id='YLCEe'></ul><sub id='YLCEe'></sub></form><legend id='YLCEe'></legend><bdo id='YLCEe'><pre id='YLCEe'><center id='YLCEe'></center></pre></bdo></b><th id='YLCEe'></th></span></q></dt></tr></i><div id='YLCEe'><tfoot id='YLCEe'></tfoot><dl id='YLCEe'><fieldset id='YLCEe'></fieldset></dl></div>
          • <legend id='YLCEe'><style id='YLCEe'><dir id='YLCEe'><q id='YLCEe'></q></dir></style></legend>
            • <bdo id='YLCEe'></bdo><ul id='YLCEe'></ul>
                  <tbody id='YLCEe'></tbody>
                  本文介绍了如何使用 C# 滚动到 WinForms TextBox 中的指定行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  如何使用 C# 滚动到 WinForms TextBox 中的指定行?

                  How can I scroll to a specified line in a WinForms TextBox using C#?

                  谢谢

                  推荐答案

                  滚动到选择的方法如下:

                  Here's how you scroll to the selection:

                  textBox.ScrollToCaret();
                  

                  要滚动到指定行,您可以遍历 TextBox.Lines 属性,将它们的长度相加以找到指定行的开头,然后设置 TextBox.SelectionStart 来定位插入符号.

                  To scroll to a specified line, you could loop through the TextBox.Lines property, total their lengths to find the start of the specified line and then set TextBox.SelectionStart to position the caret.

                  类似这样的东西(未经测试的代码):

                  Something along the lines of this (untested code):

                  int position = 0;
                  
                  for (int i = 0; i < lineToGoto; i++)
                  {
                      position += textBox.Lines[i].Length;
                  }
                  
                  textBox.SelectionStart = position;
                  
                  textBox.ScrollToCaret();
                  

                  这篇关于如何使用 C# 滚动到 WinForms TextBox 中的指定行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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# 纯数字文本框控件)
                      <bdo id='UK5Tx'></bdo><ul id='UK5Tx'></ul>
                    • <legend id='UK5Tx'><style id='UK5Tx'><dir id='UK5Tx'><q id='UK5Tx'></q></dir></style></legend>
                        <tbody id='UK5Tx'></tbody>

                          <tfoot id='UK5Tx'></tfoot>

                          1. <small id='UK5Tx'></small><noframes id='UK5Tx'>

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