RT  winform 中
我这里有几十个按钮,如果要同时切换他们的状态(就是更改它们的贴图Imgae),该怎么写代码?
难道真要像下面这样?能不能优化一下,主要从性能方面考虑,因为这样按钮有个很明显的刷新过程......                btn_ZhengFeng.Image = NoActivated;
                btn_FuPai.Image = NoActivated;
                btn_00LYan.Image = NoActivated;
                btn_1LYan.Image = NoActivated;
                btn_2LYan.Image = NoActivated;
                btn_3LYan.Image = NoActivated;
                btn_4LYan.Image = NoActivated;
                btn_ZhaoMin.Image = NoActivated;
                btn_JuanShang.Image = NoActivated;
                btn_JuanXia.Image = NoActivated;
                btn_00LLin.Image = NoActivated;
                btn_1LLin.Image = NoActivated;
                btn_2LLin.Image = NoActivated;
                btn_3LLin.Image = NoActivated;
                btn_4LLin.Image = NoActivated;
                btn_ZiDongQiDong.Image = NoActivated;
                ...  
                ...小弟虚心求教,请大家不吝赐教,先谢谢啦~!winform优化

解决方案 »

  1.   

    请问一下 在 winform 中 “把按钮的弹起状态全设置成透明的”这一步该如何实现?
      

  2.   

    一般是先把按钮设置为flat。
    摘抄以前项目里设计器里的一段,自己找下对应的属性吧。      this.button26.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
          this.button26.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
          this.button26.FlatAppearance.BorderSize = 0;
          this.button26.FlatAppearance.CheckedBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
          this.button26.FlatAppearance.MouseDownBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
          this.button26.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
          this.button26.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
          this.button26.Font = new System.Drawing.Font("宋体", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
          this.button26.Location = new System.Drawing.Point(655, 220);
          this.button26.Name = "button26";
          this.button26.Size = new System.Drawing.Size(65, 65);
          this.button26.TabIndex = 26;
          this.button26.UseVisualStyleBackColor = false;
      

  3.   

    总觉得,破破你怎么不给控件都命名好呀,这几十个按钮的,后来分得清吗?
    命名习惯一定要好~设置下Visible属性,不用的全部隐藏掉~
      

  4.   

    Visible  这个思路不错,我试试