本文整理汇总了C#中System.Windows.Forms.TextBoxBase.ScrollToCaret方法的典型用法代码示例。如果您正苦于以下问题:C# TextBoxBase.ScrollToCaret方法的具体用法?C# TextBoxBase.ScrollToCaret怎么用?C# TextBoxBase.ScrollToCaret使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.TextBoxBase
的用法示例。
在下文中一共展示了TextBoxBase.ScrollToCaret方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindRegex
internal static void FindRegex(TextBoxBase textBox, Regex regex)
{
Match match = regex.Match(textBox.Text, textBox.SelectionLength == 0 ? textBox.SelectionStart : textBox.SelectionStart + textBox.SelectionLength);
if (!match.Success)
{
WikiPad.FindForm.ShowFormattedMessageBox("No further occurences of RegularExpression \"{0}\" have been found.", regex.ToString());
return;
}
textBox.SelectionStart = match.Index;
textBox.SelectionLength = match.Length;
textBox.ScrollToCaret();
}
示例2: Find
internal static void Find(TextBoxBase textBox, string findString, bool caseSensitive, bool upwards)
{
var comparison = caseSensitive
? StringComparison.CurrentCulture
: StringComparison.CurrentCultureIgnoreCase;
var text = textBox.Text;
if (text.IndexOf(findString, comparison) == -1)
{
ShowFormattedMessageBox("Cannot find \"{0}\".", findString);
return;
}
var foundIndex = Find(text, textBox.SelectionStart, textBox.SelectionLength, findString, comparison, upwards);
if (foundIndex == -1)
{
ShowFormattedMessageBox("No further occurences of \"{0}\" have been found.", findString);
return;
}
textBox.Select(foundIndex, findString.Length);
textBox.ScrollToCaret();
}
示例3: UpdateCaret
/// <summary>
/// Repositions the caret in the defined TextBox to position _caretPosition
/// </summary>
/// <param name="textBox">Textbox to update the caret position in</param>
private void UpdateCaret(TextBoxBase textBox)
{
textBox.SelectionLength = 0;
textBox.SelectionStart = _caretPosition;
textBox.ScrollToCaret();
}
示例4: DoSearch
}//method
private bool DoSearch(TextBoxBase textBox, string fragment, int start) {
textBox.SelectionLength = 0;
// Compile the regular expression.
Regex r = new Regex(fragment, RegexOptions.IgnoreCase);
// Match the regular expression pattern against a text string.
Match m = r.Match(textBox.Text.Substring(start));
if (m.Success) {
int i = 0;
Group g = m.Groups[i];
CaptureCollection cc = g.Captures;
Capture c = cc[0];
textBox.SelectionStart = c.Index + start;
textBox.SelectionLength = c.Length;
textBox.Focus();
textBox.ScrollToCaret();
return true;
}
return false;
}//method
示例5: SetCaretAt
private static void SetCaretAt(TextBoxBase textBox, int position)
{
textBox.Focus();
textBox.SelectionStart = position;
textBox.SelectionLength = 0;
textBox.ScrollToCaret();
}
示例6: ScrollToTop
public static void ScrollToTop(TextBoxBase tb)
{
tb.SelectionStart = 0;
tb.ScrollToCaret();
}