本文整理匯總了C#中System.Windows.Forms.TextBox.GetFirstCharIndexOfCurrentLine方法的典型用法代碼示例。如果您正苦於以下問題:C# TextBox.GetFirstCharIndexOfCurrentLine方法的具體用法?C# TextBox.GetFirstCharIndexOfCurrentLine怎麽用?C# TextBox.GetFirstCharIndexOfCurrentLine使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Windows.Forms.TextBox
的用法示例。
在下文中一共展示了TextBox.GetFirstCharIndexOfCurrentLine方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: getCurrentLineNo
/// <summary>
/// Gets the current line number.
/// </summary>
/// <param name="tb">a TextBox.</param>
/// <returns>the current line number.</returns>
public static int getCurrentLineNo(TextBox tb)
{
if (tb.Lines.Length == 0)
{
return 0;
}
else
{
int startIndex = tb.GetFirstCharIndexOfCurrentLine();
return tb.GetLineFromCharIndex(startIndex);
}
}
示例2: getCurrentLineAndLineNo
/// <summary>
/// Gets a key/value pair containing currentLineNumber/currentLine.
/// </summary>
/// <param name="tb">the TextBox.</param>
/// <returns>a key/value pair containing currentLineNumber/currentLine.</returns>
public static KeyValuePair<int, String> getCurrentLineAndLineNo(TextBox tb)
{
if (tb.Lines.Length == 0)
{
return new KeyValuePair<int, String>(0,tb.Text);
}
else
{
int startIndex = tb.GetFirstCharIndexOfCurrentLine();
int currentLineNumber = tb.GetLineFromCharIndex(startIndex);
return new KeyValuePair<int,String>(currentLineNumber, tb.Lines[currentLineNumber]);
}
}
示例3: getCurrentLine
/// <summary>
/// Gets the current line from a TextBox control.
/// </summary>
/// <param name="tb">the TextBox control.</param>
/// <returns>the current line.</returns>
public static String getCurrentLine(TextBox tb)
{
if (tb.Lines.Length == 0)
{
return tb.Text;
}
else
{
int startIndex = tb.GetFirstCharIndexOfCurrentLine();
int currentLineNumber = tb.GetLineFromCharIndex(startIndex);
return tb.Lines[currentLineNumber];
}
}
示例4: UpdateCursorLocation
protected void UpdateCursorLocation(TextBox tb)
{
cursorLineNo = tb.GetLineFromCharIndex(tb.SelectionStart) + 1;
cursorColumnNo = tb.SelectionStart - tb.GetFirstCharIndexOfCurrentLine() + 1;
// Update cursor position on status bar:
mainStatusStripCursorPosLabel.Text = "(" + cursorLineNo.ToString() + ", " +
cursorColumnNo.ToString() + ")";
}