本文整理汇总了C#中System.Windows.Forms.RichTextBox.GetFirstCharIndexOfCurrentLine方法的典型用法代码示例。如果您正苦于以下问题:C# RichTextBox.GetFirstCharIndexOfCurrentLine方法的具体用法?C# RichTextBox.GetFirstCharIndexOfCurrentLine怎么用?C# RichTextBox.GetFirstCharIndexOfCurrentLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.RichTextBox
的用法示例。
在下文中一共展示了RichTextBox.GetFirstCharIndexOfCurrentLine方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetTabsOnLine
private static string GetTabsOnLine(RichTextBox rt)
{
bool count = true;
int i = rt.GetFirstCharIndexOfCurrentLine();
StringBuilder sb = new StringBuilder();
while (count)
{
if (i < rt.Text.Length)
{
count = rt.Text[i] == '\t';
i++;
if (count)
{
sb.Append("\t");
}
}
else
{
count = false;
}
}
return sb.ToString();
}
示例2: GetClippingRectangle
private Rectangle GetClippingRectangle(RichTextBox rtbText)
{
int index = rtbText.GetFirstCharIndexOfCurrentLine();
Point point = rtbText.GetPositionFromCharIndex(index);
return new Rectangle(point, new Size(200, 119));
}
示例3: getCurrentLine
/// <summary>
/// Gets the current line from a RichTextBox control.
/// </summary>
/// <param name="rtb">the RichTextBox control.</param>
/// <returns>the current line.</returns>
public static String getCurrentLine(RichTextBox rtb)
{
if (rtb.Lines.Length == 0)
{
return rtb.Text;
}
else
{
int startIndex = rtb.GetFirstCharIndexOfCurrentLine();
int currentLineNumber = rtb.GetLineFromCharIndex(startIndex);
return rtb.Lines[currentLineNumber];
}
}
示例4: getCurrentLineNo
/// <summary>
/// Gets the current line number.
/// </summary>
/// <param name="tb">a RichTextBox.</param>
/// <returns>the current line number.</returns>
public static int getCurrentLineNo(RichTextBox rtb)
{
if (rtb.Lines.Length == 0)
{
return 0;
}
else
{
int startIndex = rtb.GetFirstCharIndexOfCurrentLine();
return rtb.GetLineFromCharIndex(startIndex);
}
}
示例5: 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(RichTextBox rtb)
{
if (rtb.Lines.Length == 0)
{
return new KeyValuePair<int, String>(0, rtb.Text);
}
else
{
int startIndex = rtb.GetFirstCharIndexOfCurrentLine();
int currentLineNumber = rtb.GetLineFromCharIndex(startIndex);
return new KeyValuePair<int, String>(currentLineNumber, rtb.Lines[currentLineNumber]);
}
}
示例6: GetCurrentLineStartIndex
public static int GetCurrentLineStartIndex(RichTextBox richTextbox) {
return richTextbox.GetFirstCharIndexOfCurrentLine();
}
示例7: r_SelectionChanged
public void r_SelectionChanged(object sender, EventArgs e)
{
r = GetCurrentRichTextBox();
Font currFont;
//说明:判断有无选择字符串可根据SelectionLength来判断;
//SelectionFont 等于null 并不等于没有选择字符串,可能是由于所选择的
// 字符串中同时包含多个字体
if (r.SelectionFont != null)
{
currFont = r.SelectionFont;
tf.SelectedIndex = tf.FindString(currFont.Name);
//设置粗体按钮
//if ((editor.SelectionFont.Style & FontStyle.Bold) == FontStyle.Bold) tSBtnBold.Checked = true; else tSBtnBold.Checked = false;
tSBtnBold.Checked = r.SelectionFont.Bold;
tSBtnItalic.Checked = r.SelectionFont.Italic;
tSBtnUnderline.Checked = r.SelectionFont.Underline;
}
else
tf.SelectedIndex = -1;
toolStripStatusLabel3.Text = "(光标)当前位置:行:" + r.GetLineFromCharIndex(r.SelectionStart).ToString();
toolStripStatusLabel3.Text += " 列:" + (r.SelectionStart - r.GetFirstCharIndexOfCurrentLine()).ToString();
setAlign(r.SelectionAlignment); //设置对齐方式按钮的多选一效果
}