<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 中的指定行?

        时间:2023-06-09
        <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 中的指定行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何在 Windows 窗体 TextBox 控件中设置 TAB 宽度? 下一篇:如何通过鼠标拖动来选择多个控件

                  相关文章

                    <bdo id='UK5Tx'></bdo><ul id='UK5Tx'></ul>
                1. <legend id='UK5Tx'><style id='UK5Tx'><dir id='UK5Tx'><q id='UK5Tx'></q></dir></style></legend>

                    <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>