zoukankan      html  css  js  c++  java
  • C#多个控件有同一个事件,优化

    先自己声明方法,,再用事件调用;

     public void borderS3D(object sender,EventArgs e)
            {
                   ((PictureBox)sender).BorderStyle=BorderStyle.Fixed3D;         
            }
    public void borderSNo(object sender, EventArgs e) { ((PictureBox)sender).BorderStyle = BorderStyle.None; }
     public FormMain()
            {
                InitializeComponent();
                pictureBox1.MouseHover += new  EventHandler(borderS3D);
                pictureBox1.MouseLeave += new EventHandler(borderSNo);
    
                pictureBox2.MouseHover += new EventHandler(borderS3D);
                pictureBox2.MouseLeave += new EventHandler(borderSNo);
    
                pictureBox3.MouseHover += new EventHandler(borderS3D);
                pictureBox3.MouseLeave += new EventHandler(borderSNo);
    
                pictureBox4.MouseHover += new EventHandler(borderS3D);
                pictureBox4.MouseLeave += new EventHandler(borderSNo);
    
                pictureBox5.MouseHover += new EventHandler(borderS3D);
                pictureBox5.MouseLeave += new EventHandler(borderSNo);
    
                pictureBox6.MouseHover += new EventHandler(borderS3D);
                pictureBox6.MouseLeave += new EventHandler(borderSNo);
    
                pictureBox7.MouseHover += new EventHandler(borderS3D);
                pictureBox7.MouseLeave += new EventHandler(borderSNo);
    
                pictureBox8.MouseHover += new EventHandler(borderS3D);
                pictureBox8.MouseLeave += new EventHandler(borderSNo);
    
                pictureBox9.MouseHover += new EventHandler(borderS3D);
                pictureBox9.MouseLeave += new EventHandler(borderSNo);
    
                pictureBox10.MouseHover += new EventHandler(borderS3D);
                pictureBox10.MouseLeave += new EventHandler(borderSNo);
    
                pictureBox11.MouseHover += new EventHandler(borderS3D);
                pictureBox11.MouseLeave += new EventHandler(borderSNo);
    
               
            }
  • 相关阅读:
    Installutil.exe的位置和路径
    .net服务安装(转载)
    移动程序云测试中心
    如何通过web地址直接调用webservices
    VC++引用类型与指针类型
    Android模拟 HTTP multipart/formdata 请求协议信息实现图片上传
    firefox看网页的插件
    DOS下输入汉字
    电脑APK
    HDOJ 1071(球泡无线和直线区域内的面积)
  • 原文地址:https://www.cnblogs.com/janeaiai/p/5072936.html
Copyright © 2011-2022 走看看