如何增加动态标签的字体大小? [英] how to increase the font size of a dynamic label?

查看:136
本文介绍了如何增加动态标签的字体大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此代码给出2个错误
1)对于"System.Drawing.Size.Size(System.Drawing.Point)"的最佳重载方法匹配具有一些无效的参数"
2)参数"1":无法从"int"转换为"System.Drawing.Point"
参数"1"表示传递给Size()的值.
还有其他增加动态标签字体大小的方法吗?是否可以对动态按钮采用同样的方法?请有人帮忙吗?

this code gives 2 errors
1)"The best overloaded method match for ''System.Drawing.Size.Size(System.Drawing.Point)'' has some invalid arguments"
2) Argument ''1'': cannot convert from ''int'' to ''System.Drawing.Point''
Argument ''1'' means the value passed to Size().
Is there any other way of increasing the font size of a dynamic label?Can we apply it on same way for the dynamic buttons also?Please can any one help me?

Label[] lab = new Label[20];
int x = 240;
for (int i = 1; i <= 10; i++)
{
 lab[i] = new Label();
 lab[i].Text = Convert.ToString(i);
 lab[i].Location = new Point(70,x);
 lab[i].Font.Size = new Size(10); 
 lab[i].Size = new Size(35,13);
 x = x + 95;
}
this.Controls.AddRange(lab);



thanx!



thanx!

推荐答案

地球上没有理由说动态控件的工作原理有所不同,因此问题必须出在核心代码上.
字体大小是浮动的,就像错误消息说的那样.您应该使用intellisense或文档来准确确定参数所需的条件,尤其是在参数出现错误以告知您输入错误的情况下.另外,Size需要两个参数,而不是一个.就像您为整体大小所做的一样.
There is no reason on earth why a dynamic control would work any differently, so the issue must be with the core code.

Font size is a float, just like the error message says. You should use intellisense, or perhaps the docs, to work out exactly what a parameter requires, esp when it gives you an error to tell you that you got it wrong. Also, Size takes two parameters, not one. Just like you did for the overall Size.


是的,您需要整体替换它,而不仅仅是修改属性.请参见各种字体构造函数的重载 [
Yes, you need to replace it in its entirety, not just modify a property. See the various overloads of the Font constructors[^]:
lab[i].Font = new Font ( lab[i].Font.FontFamily, 10 );


这篇关于如何增加动态标签的字体大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆