本文整理汇总了C#中TextBox.ScrollToCaret方法的典型用法代码示例。如果您正苦于以下问题:C# TextBox.ScrollToCaret方法的具体用法?C# TextBox.ScrollToCaret怎么用?C# TextBox.ScrollToCaret使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextBox
的用法示例。
在下文中一共展示了TextBox.ScrollToCaret方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MainForm
public MainForm ()
{
//
// _textBox
//
_textBox = new TextBox ();
_textBox.Dock = DockStyle.Fill;
_textBox.Multiline = true;
_textBox.Text += "sample text" + System.Environment.NewLine;
_textBox.Text += "sample text" + System.Environment.NewLine;
_textBox.Text += "sample text" + System.Environment.NewLine;
_textBox.Text += "sample text" + System.Environment.NewLine;
_textBox.Text += "sample text" + System.Environment.NewLine;
_textBox.Text += "sample text" + System.Environment.NewLine;
_textBox.Text += "sample text" + System.Environment.NewLine;
_textBox.Text += "sample text" + System.Environment.NewLine;
_textBox.Text += "sample text" + System.Environment.NewLine;
_textBox.Text += "sample text" + System.Environment.NewLine;
_textBox.Text += "sample text" + System.Environment.NewLine;
_textBox.Text += "sample text" + System.Environment.NewLine;
_textBox.ScrollToCaret ();
Controls.Add (_textBox);
//
// _testMenu
//
_testMenu = new MenuItem ("&Test");
_testMenu.MenuItems.Add (new MenuItem ("Option 1"));
_testMenu.MenuItems.Add (new MenuItem ("Option 2"));
_testMenu.MenuItems.Add (new MenuItem ("Option 3"));
//
// MainForm
//
ClientSize = new Size (300, 300);
Location = new Point (250, 100);
Menu = new MainMenu ();
Menu.MenuItems.Add (_testMenu);
StartPosition = FormStartPosition.Manual;
Text = "bug #333548";
Load += new EventHandler (MainForm_Load);
}
示例2: ScrollToLastLine
public static void ScrollToLastLine(TextBox tb)
{
var pos = tb.Text.LastIndexOf(Environment.NewLine) + 2;
if (pos > -1)
tb.SelectionStart = pos;
tb.ScrollToCaret();
}