标签控件的运用:一长串英文字符,不明白这边的new是什么意思
标签控件的运用:一长串英文字符,不明白这里的new是什么意思?
【例9-8】标签控件的运用。
窗体上3个标签:lable1,lable2,lable3。对窗体上的3个标签控件的参数进行设置,用来显示文本。
代码如下:
namespace 练习
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
//label1参数设置
this.label1.AutoSize = true;
this.label1.BackColor = System.Drawing.Color.White;
this.label1.Text = "宋体9号--白底--黑字";
//label2参数设置
this.label2.AutoSize = true;
this.label2.BackColor = System.Drawing.Color.Black;
this.label2.Font = new System.Drawing.Font(
"宋体",10.5F,System.Drawing .FontStyle .Regular ,
System.Drawing .GraphicsUnit .Point ,((byte)(134)));
this.label2.ForeColor = System.Drawing.Color.White;
this.label2.Text = "宋体10号--黑底--白字";
//label3参数设置
this.label3.AutoSize = true;
this.label3.BackColor = System.Drawing.Color.Blue;
this.label3.Font = new System.Drawing.Font(
"楷体_GB2312",14.25F,System.Drawing .FontStyle .Regular ,
System.Drawing .GraphicsUnit .Point ,((byte)(134)));
this.label3.ForeColor = System.Drawing.Color.Red;
this.label3.Text = "楷体14号--蓝底--红字";
}
}
}
(1)我的困惑
首先说明,我刚刚自学C#,英文基础相对较弱。对于上面代码中的语句,不理解,不懂,或者说不知道是什么的是这句:
lable2里的:
this.label2.Font = new System.Drawing.Font(
"宋体",10.5F,System.Drawing .FontStyle .Regular ,
System.Drawing .GraphicsUnit .Point ,((byte)(134)));
困惑的集中点是:
1)new ,这里为什么要new?
2)System.Drawing .FontStyle .Regular 是什么意思?
3)System.Drawing .GraphicsUnit .Point?
4)((byte)(134))这又是什么?
我只知道这语句是改变默认字体、字号。只知其然,不知其所以然。现在,我想知道“其所以然”。
(2)在此请教各位大侠,希望大侠们不吝赐教!小虾在此先谢谢了!还有,请高手大侠们不要笑小虾,小虾我断断续续、点点滴滴的自学中,常常遇到一些较低级别的问题。对于大侠们,是小问题,可对于我这只小虾,却是一个关卡。
------解决思路----------------------
学会自己搜索吧。恐怕 你都不知道有http://msdn.microsoft.com/library/这个网址。
------解决思路----------------------
你先去看看C#类、属性、字段、数据类型吧
------解决思路----------------------
像System.Drawing .FontStyle .Regular , System.Drawing .GraphicsUnit .Point 这些都是属性,用翻译词典将Regular 、Point 翻译出来,从翻译出的字面意思去理解这个属性的含义。
【例9-8】标签控件的运用。
窗体上3个标签:lable1,lable2,lable3。对窗体上的3个标签控件的参数进行设置,用来显示文本。
代码如下:
namespace 练习
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
//label1参数设置
this.label1.AutoSize = true;
this.label1.BackColor = System.Drawing.Color.White;
this.label1.Text = "宋体9号--白底--黑字";
//label2参数设置
this.label2.AutoSize = true;
this.label2.BackColor = System.Drawing.Color.Black;
this.label2.Font = new System.Drawing.Font(
"宋体",10.5F,System.Drawing .FontStyle .Regular ,
System.Drawing .GraphicsUnit .Point ,((byte)(134)));
this.label2.ForeColor = System.Drawing.Color.White;
this.label2.Text = "宋体10号--黑底--白字";
//label3参数设置
this.label3.AutoSize = true;
this.label3.BackColor = System.Drawing.Color.Blue;
this.label3.Font = new System.Drawing.Font(
"楷体_GB2312",14.25F,System.Drawing .FontStyle .Regular ,
System.Drawing .GraphicsUnit .Point ,((byte)(134)));
this.label3.ForeColor = System.Drawing.Color.Red;
this.label3.Text = "楷体14号--蓝底--红字";
}
}
}
(1)我的困惑
首先说明,我刚刚自学C#,英文基础相对较弱。对于上面代码中的语句,不理解,不懂,或者说不知道是什么的是这句:
lable2里的:
this.label2.Font = new System.Drawing.Font(
"宋体",10.5F,System.Drawing .FontStyle .Regular ,
System.Drawing .GraphicsUnit .Point ,((byte)(134)));
困惑的集中点是:
1)new ,这里为什么要new?
2)System.Drawing .FontStyle .Regular 是什么意思?
3)System.Drawing .GraphicsUnit .Point?
4)((byte)(134))这又是什么?
我只知道这语句是改变默认字体、字号。只知其然,不知其所以然。现在,我想知道“其所以然”。
(2)在此请教各位大侠,希望大侠们不吝赐教!小虾在此先谢谢了!还有,请高手大侠们不要笑小虾,小虾我断断续续、点点滴滴的自学中,常常遇到一些较低级别的问题。对于大侠们,是小问题,可对于我这只小虾,却是一个关卡。
------解决思路----------------------
学会自己搜索吧。恐怕 你都不知道有http://msdn.microsoft.com/library/这个网址。
------解决思路----------------------
你先去看看C#类、属性、字段、数据类型吧
------解决思路----------------------
像System.Drawing .FontStyle .Regular , System.Drawing .GraphicsUnit .Point 这些都是属性,用翻译词典将Regular 、Point 翻译出来,从翻译出的字面意思去理解这个属性的含义。