日期:2014-05-18  浏览次数:20704 次

其实高亮文字很容易实现。。。
C# code
using System;
using System.Text;
using System.Text.RegularExpressions;

public class HighBright
{
    public enum ChooseColorForText
    {
        Red, Green, Blue, Yellow, Black, Orange, Sienna, LightPink,
    }

    public enum ChooseSizeForText
    {
        A1 = 50, A2 = 40, A3 = 30, A4 = 20, A5 = 10,
    }

    public static string ChangeKeyWordColor(string strHtml, string strKeyWord, ChooseColorForText color, ChooseSizeForText size)
    {
        return Regex.Replace(strHtml, strKeyWord, "<font color=\"" + color + "\"><b style=\"font-size:" + (int)size + "px;\">" + strKeyWord+ "</b></font>\n", RegexOptions.IgnoreCase);
    }
}
 Response.Write(HighBright.ChangeKeyWordColor("abc", "a", HighBright.ChooseColorForText.Blue, HighBright.ChooseSizeForText.A1));
//显示结果如下:




HTML code
><font color="Blue"><b style="font-size: 50px;">a</b></font>
bc


------解决方案--------------------
收获不小,接分
------解决方案--------------------
我还以为是WinForm里面的高亮文字呢。