文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>设置RichTextBox部分字体

设置RichTextBox部分字体

时间:2011-06-01  来源:xcanel

 #region 设置消息显示加粗
        /// <summary>
        /// 设置消息显示加粗
        /// </summary>
        /// <param name="textBox"></param>
        /// <returns></returns>
        public RichTextBox SetFontColor(RichTextBox textBox)
        {
            //定义热点关键字
            List<string> lsCommand = new List<string>();
            lsCommand.Add("热点1");
            lsCommand.Add("热点2");

          

            for (int ICmdPra = 0; ICmdPra < lsCommand.Count; ICmdPra++)
            {
                try
                {
                    if (!textBox.Text.Contains(lsCommand[ICmdPra]))
                        continue;
                    string[] list = new string[1];
                    list[0] = lsCommand[ICmdPra];
                    string[] hotPoint = textBox.Text.ToLower().Split(list, System.StringSplitOptions.RemoveEmptyEntries);
                    //字体设置起始位置
                    int setIndex = 0;
                    for (int hotIndex = 0; hotIndex < hotPoint.Length; hotIndex++)
                    {
                        setIndex = setIndex + hotPoint[hotIndex].Length;
                        //设置关键字颜色
                        textBox.Select(setIndex, lsCommand[ICmdPra].Length);
                        textBox.SelectionColor = Color.Red;
                        textBox.SelectionFont = new Font(textBox.Font, textBox.Font.Style | FontStyle.Bold);

                        setIndex = setIndex + lsCommand[ICmdPra].Length;
                    }
                }
                catch (Exception ex)
                {
                    AppLog.Write("LiNing.Client.FrmMain.backgroundWorker1_DoWork", AppLog.LogMessageType.Fatal, ex);
                }
            }
            return textBox;
        }
        #endregion

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载