动态改变控件的样式(Css)
(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类并赋给控件
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
ApplyStyle()方法覆盖了控件的旧样式,而MergeStyle()则不会覆盖现存的属性。