【发布时间】:2016-11-18 12:58:58
【问题描述】:
我正在尝试使用此代码在运行时更改文本框和组合框字体
combobox1.Font = new Font("Tamil", 12, FontStyle.Bold);
使用此代码,只有字体样式变为粗体,字体大小变为 12,但字体(语言“泰米尔语”)没有变化。
如果我更改属性中的字体,这意味着它可以工作,但在运行时它不会改变。
我的编码是否有任何错误或在运行时更改字体的任何其他方式?
解决方案
我发现这是错字。以下是我当前的代码。 问题的原因是字体拼写错误
FontFamily fontFamily = new FontFamily("senthamil");
Font font = new Font( fontFamily, 16, FontStyle.Regular, GraphicsUnit.Pixel);
cmb_Product_Code.Font = new System.Drawing.Font("senthamil", 12F,System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
【问题讨论】:
-
我认为格式不正确。尝试这样的事情。
comboBox1.Font = new System.Drawing.Font("Tamil", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))) -
谢谢您的回复先生..这也不起作用先生...同样的结果只是字体样式和大小发生变化,但字体没有变化
-
@Sivashankar 你确定你有那种字体样式吗?去
Control Panel -> Appearance and Personalization -> Fonts检查是否安装了Tamil字体。 -
@active92 如果未安装字体,则表示使用此代码未找到字体等错误 FontFamily fontFamily = new FontFamily("senthamil");字体字体 = new Font(fontFamily, 16, FontStyle.Regular, GraphicsUnit.Pixel);但我使用此代码 cmb_Product_Code.Font = new System.Drawing.Font("senthamil", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));它不会显示它跳过的错误这是两种代码之间的唯一区别
标签: c#