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()则不会覆盖现存的属性。
       

  • 相关阅读:
    MacOS Sierra允许运行任何来源的程序
    Windows Server2008 R2中的角色
    Linux根目录解析
    Linux安装配置SVN服务器
    Linux6.x修改出eth0网卡的解决方法
    如何利用mount命令挂载另一台服务器上的目录
    Arcgis水文分析-Dem提取集水区
    前端布局之Flex布局
    其实我就是想好好的写写代码(一个伪程序猿的独白)
    WebApi关于配置全局返回Json数据格式时间以及命名小写
  • 原文地址:https://www.cnblogs.com/ghx88/p/348944.html
Copyright © 2011-2022 走看看