本文整理汇总了C#中System.Windows.Forms.RichTextBox.SetCharFormat方法的典型用法代码示例。如果您正苦于以下问题:C# RichTextBox.SetCharFormat方法的具体用法?C# RichTextBox.SetCharFormat怎么用?C# RichTextBox.SetCharFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.RichTextBox
的用法示例。
在下文中一共展示了RichTextBox.SetCharFormat方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: applyLinkStyle
private static void applyLinkStyle(RichTextBox rtb, List<KeyValuePair<int, int>> links)
{
// apply links style
CHARFORMAT ncf = new CHARFORMAT(CFM.LINK, CFE.LINK);
foreach (var pair in links)
{
rtb.Select(pair.Key, pair.Value);
rtb.SetCharFormat(ncf);
}
}
示例2: HandleTextAndWhitespace
private static PARAFORMAT HandleTextAndWhitespace(RichTextBox rtb, PARAFORMAT pf, CHARFORMAT cf, string strData)
{
bool bNewParagraph = (strData.IndexOf("\r\n", 0) >= 0) || (strData.IndexOf("\n", 0) >= 0);
if (strData.Length > 0)
{
// now, add text to control
int nStartCache = rtb.SelectionStart;
rtb.SelectedText = strData;
rtb.Select(nStartCache, strData.Length);
// apply format
rtb.SetParaFormat(pf);
rtb.SetCharFormat(cf);
}
// reposition to final
rtb.Select(rtb.TextLength + 1, 0);
// new paragraph requires to reset alignment
if (bNewParagraph)
{
pf.dwMask = PFM.ALIGNMENT | PFM.NUMBERING;
pf.wAlignment = PFA.LEFT;
pf.wNumbering = 0;
}
return pf;
}
示例3: ProcessSignificantWhitespace
private static bool ProcessSignificantWhitespace(RichTextBox rtb, ref CHARFORMAT cf, ref PARAFORMAT pf, string strData)
{
bool bNewParagraph = (strData.IndexOf("\r\n", 0) >= 0) || (strData.IndexOf("\n", 0) >= 0);
if (strData.Length > 0)
{
// now, add text to control
int nStartCache = rtb.SelectionStart;
rtb.SelectedText = strData;
rtb.Select(nStartCache, strData.Length);
// apply format
rtb.SetParaFormat(pf);
rtb.SetCharFormat(cf);
}
// reposition to final
rtb.Select(rtb.TextLength + 1, 0);
return bNewParagraph;
}