DCAgile 发表于 2015-9-28 13:46:00

TX TextControl控件字体、字体颜色设置相关问题

问题:

1.如何设置字体大小、颜色??

2.模版中包括某些特殊字符,需要特殊显示(加粗或其他颜色),对于哪些字符需要特殊显示需要可配置。
例如包括以下字符:癌、瘤、病、上、下、左、右——需要做特殊处理(编辑时改变字体以及字体颜色,打印时,需将字体设置为默认值),如何实现??

Alice 发表于 2015-9-28 17:13:00

回复 1楼DCAgile的帖子

谢谢对该问题的反馈。
1.如果是设置文字的颜色,可以使用TextControl.ForeColor属性。文字的背景色设置TextControl.TextBackColor,字体使用ServerTextControl.Font 设置。
详细的情参考产品文档:http://www.textcontrol.com/en_US/support/documentation/dotnet/n_categories.char.htm

2.你可以设置InputFormat来格式化输入位置的当前文字。
比如加黑,改变大小。
文档请参考
http://www.textcontrol.com/en_US/support/documentation/dotnet/n_inputformat.htm
也可以通过TextControl.CharFormatChanged事件对相关选择文字或是当前输入文字的输入改变时候去格式化文字。文档请参考:
http://www.textcontrol.com/en_US/support/documentation/dotnet/n_textcontrol.charformatchanged.htm

iceman 发表于 2015-10-12 15:18:00

回复 1楼DCAgile的帖子

测试方法如下:

            this.textControl1.Text = "癌zhegnhaun癌fdsfds癌";

            int index = -1;

            do
            {
                index = this.textControl1.Find("癌", index + 1,
                  TXTextControl.FindOptions.NoMessageBox);

                this.textControl1.Selection.ForeColor = Color.Red;
            } while (index != -1);


打印时候建议保存一个副本,然后使用 ServerTextControl 操作,避免二次查找。

DCAgile 发表于 2015-10-13 10:15:00

回复 3楼iceman的帖子

如附件所示:
Form1_Load事件中实现加载内容;
textControl1_Changed进行样式设置;

如: List<string> list = new List<string>();
            list.Add("上");
            list.Add("下");
            list.Add("重病");
            list.Add("可见");
如果存在list中内容需要设置为红色字体

问题:
1.将 “上” 通过编辑更改为非 “list ”中的内容仍然为红色???
2.如何控制TX Control处于非选择状态——即样式更改完成后不做任何内容的选择???

DCAgile 发表于 2015-10-13 11:34:00

回复 4楼DCAgile的帖子

刚电话沟通的问题:

在循环外记忆位置的话,就需要能够获取当用户当前的鼠标 光标所在位置???

如何获取鼠标光标位置??

iceman 发表于 2015-10-13 12:21:00

回复 4楼DCAgile的帖子

第一个问题我理解是如何使输入的文本格式不延续输入位置之前的文本,目前我还没有找到这个属性,需要咨询厂商后反馈给你。

iceman 发表于 2015-10-13 12:28:00

回复 5楼DCAgile的帖子

问题二,看看以下代码能否实现你想要的效果:

private void SetSpecialStyle()
      {
            int start = this.textControl1.Selection.Start;
            List<string> list = new List<string>();
            list.Add("上");
            list.Add("下");
            list.Add("重病");
            list.Add("可见");
            int index = -1;
            for (int i = 0; i < list.Count; i++)
            {
                do
                {
                  index = this.textControl1.Find(list, index + 1, TXTextControl.FindOptions.NoMessageBox);

                  this.textControl1.Selection.ForeColor = Color.Red;
                } while (index != -1);
            }
            this.textControl1.Select(start,0);
      }

iceman 发表于 2015-10-14 09:33:00

回复 6楼iceman的帖子

问题一可以通过 “InputPositionChanged ”事件进行设置, 新输入文字继承前方文字样式是产品设计需要通过代码手动更改。

DCAgile 发表于 2015-10-14 09:51:00

回复 8楼iceman的帖子

private void textControl1_InputPositionChanged(object sender, EventArgs e)
      {
            Font font = new Font(DefaultFont, FontStyle.Regular);
            this.textControl1.ForeColor = Color.Black;
      }
使用如上代码进行设置 无效

应该如何设置???

iceman 发表于 2015-10-14 11:33:00

回复 9楼DCAgile的帖子

textControl1.ForeColor 是继承与 Control 的属性,没有具体实现。可以通过以下方法设置:

      private void textControl1_InputPositionChanged(object sender, EventArgs e)
      {
            this.textControl1.Selection.ForeColor = Color.Black;
      }
页: [1] 2 3
查看完整版本: TX TextControl控件字体、字体颜色设置相关问题