RichTextBox加粗行首关键词

it2022-05-09  19

实现如下效果:

一开始想法是查找关键词,根据关键词是前有回车符来过滤,后来在上请教高手,

这样实现的:

string key = Regex.Escape( " 水动力条件 " );Regex reg = new Regex( @" (?m)^ " + key);MatchCollection mc = reg.Matches(rtbZRGK.Text); foreach (Match m in mc) { rtbZRGK.SelectionStart = m.Index; rtbZRGK.SelectionLength = m.Value.Length; rtbZRGK.SelectionFont = new Font(rtbZRGK.SelectionFont, FontStyle.Bold); }

 

学习了

转载于:https://www.cnblogs.com/wuenping/archive/2010/05/03/1726251.html

相关资源:数据结构—成绩单生成器

最新回复(0)