zoukankan      html  css  js  c++  java
  • 动态改变控件的样式(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类并赋给控件

            private void Button1_Click(object sender, System.EventArgs e)
            
    {
                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()则不会覆盖现存的属性。
       

  • 相关阅读:
    js 表格上下移动 javascript实现
    存储过程-----DECLARE---实用注意事项
    储存过程-原理、语法、函数详细说明
    第九章 接口
    第八章 多态
    第七章 类复用
    synchronized ---- 作用
    集合框架综述
    java static代码块执行时机
    状态模式
  • 原文地址:https://www.cnblogs.com/ghx88/p/348944.html
Copyright © 2011-2022 走看看