C#使用RichTextBox实现替换文字及改变字体颜色功能示例-创新互联
本文实例讲述了C#使用RichTextBox实现替换文字及改变字体颜色功能。分享给大家供大家参考,具体如下:

替换文字
private void GenerateEntity()
{
try
{
string result = ChangeWords("specific content...");
txtContent.Text = result;
ChangeColor();
}
catch (Exception ex)
{
MessageBox.Show("类生成失败!错误信息:" + ex.Message);
}
}
private string ChangeWords(string content)
{
//先替换"nvarchar"、"varchar"、"nchar",再替换"char"
//不然"nvarchar"、"varchar"、"nchar"就会被替换为
//nvarstring"、"varstring"、"nstring"不能进行原有规则替换
string result = Regex.Replace(content, "nvarchar", "string");
//进行下一步替换的时一定要以上一步替换的返回结果为数据源而不是content
//因为content值没有改变
result = Regex.Replace(result, "varchar", "string");
result = Regex.Replace(result, "nchar", "string");
result = Regex.Replace(result, "char", "string");
result = Regex.Replace(result, "tinyint", "int");
result = Regex.Replace(result, "smallint", "int");
result = Regex.Replace(result, "bigint", "int");
result = Regex.Replace(result, "datetime", "DateTime");
return result;
}
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
当前题目:C#使用RichTextBox实现替换文字及改变字体颜色功能示例-创新互联
本文网址:http://www.jxjierui.cn/article/dococg.html


咨询
建站咨询
