(1)Style属性
private void btnUpload_Click(object sender, System.EventArgs e)
{
Label1.Style("text-transform") = "Capitalize";
}
(2)cssClass属性
<html>
<head>
<style>
.myClass1
{
font:18pt script;
color: red;
}
.myClass2
{
font:24pt script;
color: blue;
}
</style>
</head>
……
……
</html>
private void btnUpload_Click(object sender, System.EventArgs e)
{
Label1.cssClass ="myClass2";
}
(3)生成Style类并赋给控件
{
Style s = new Style();
s.BackColor = Color.Yellow;
s.ForeColor = Color.Red;
s.BorderStyle = BorderStyle.Dashed;
s.BorderWidth = new Unit(4);
this.TextBox1.ApplyStyle(s);
this.TextBox2.MergeStyle(s);
}
ApplyStyle()方法覆盖了控件的旧样式,而MergeStyle()则不会覆盖现存的属性。