找回密码
 立即注册

QQ登录

只需一步,快速开始

DCAgile

中级会员

83

主题

247

帖子

794

积分

中级会员

积分
794

活字格认证微信认证勋章元老葡萄

DCAgile
中级会员   /  发表于:2015-9-28 13:46  /   查看:17727  /  回复:24
问题:

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

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

24 个回复

倒序浏览
Alice
社区贡献组   /  发表于:2015-9-28 17:13:00
沙发
回复 1楼DCAgile的帖子

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

2.你可以设置InputFormat来格式化输入位置的当前文字。
比如加黑,改变大小。
文档请参考
http://www.textcontrol.com/en_US ... t/n_inputformat.htm
也可以通过TextControl.CharFormatChanged事件对相关选择文字或是当前输入文字的输入改变时候去格式化文字。文档请参考:
http://www.textcontrol.com/en_US ... arformatchanged.htm
请点击评分,对我的服务做出评价!  5分为非常满意!

葡萄城控件服务团队

官方网站: http://www.gcpowertools.com.cn
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2015-10-12 15:18:00
板凳
回复 1楼DCAgile的帖子

测试方法如下:

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

  2.             int index = -1;

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

  7.                 this.textControl1.Selection.ForeColor = Color.Red;
  8.             } 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处于非选择状态——即样式更改完成后不做任何内容的选择???

CombineDocs.rar

62.78 KB, 下载次数: 191

回复 使用道具 举报
DCAgile
中级会员   /  发表于:2015-10-13 11:34:00
5#
回复 4楼DCAgile的帖子

刚电话沟通的问题:

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

如何获取鼠标光标位置??
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2015-10-13 12:21:00
6#
回复 4楼DCAgile的帖子

第一个问题我理解是如何使输入的文本格式不延续输入位置之前的文本,目前我还没有找到这个属性,需要咨询厂商后反馈给你。
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2015-10-13 12:28:00
7#
回复 5楼DCAgile的帖子

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

  1. private void SetSpecialStyle()
  2.         {
  3.             int start = this.textControl1.Selection.Start;
  4.             List<string> list = new List<string>();
  5.             list.Add("上");
  6.             list.Add("下");
  7.             list.Add("重病");
  8.             list.Add("可见");
  9.             int index = -1;
  10.             for (int i = 0; i < list.Count; i++)
  11.             {
  12.                 do
  13.                 {
  14.                     index = this.textControl1.Find(list[i], index + 1, TXTextControl.FindOptions.NoMessageBox);

  15.                     this.textControl1.Selection.ForeColor = Color.Red;
  16.                 } while (index != -1);
  17.             }
  18.             this.textControl1.Select(start,0);
  19.         }
复制代码
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2015-10-14 09:33:00
8#
回复 6楼iceman的帖子

问题一可以通过 “InputPositionChanged ”事件进行设置, 新输入文字继承前方文字样式是产品设计需要通过代码手动更改。
回复 使用道具 举报
DCAgile
中级会员   /  发表于:2015-10-14 09:51:00
9#
回复 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
10#
回复 9楼DCAgile的帖子

textControl1.ForeColor 是继承与 Control 的属性,没有具体实现。可以通过以下方法设置:
  1.         private void textControl1_InputPositionChanged(object sender, EventArgs e)
  2.         {
  3.             this.textControl1.Selection.ForeColor = Color.Black;
  4.         }
复制代码

评分

参与人数 1满意度 +5 收起 理由
DCAgile + 5 问题已解决....

查看全部评分

回复 使用道具 举报
123下一页
您需要登录后才可以回帖 登录 | 立即注册
返回顶部