WinForm中Button的使用

时间:2024-11-21 17:05:07
  • 自定义样式
    • 先要清除系统风格影响:this.FlatStyle = FlatStyle.Flat;
      • FlatStyle.Flat
      • FlatStyle.System
      • FlatStyle.Standard
      • FlatStyle.Popup
    • 位置:this.Location = new System.Drawing.Point(this.sidePadding + this.btnWidth, 0);
    • 大小:this.Size = new System.Drawing.Size(btnWidth, btnHeight);
    • 前景色:this.ForeColor = Color.White;
    • 背景色(字体颜色):this.BackColor = Color.FromArgb(35, 135, 170);
    • 背景图片:this.BackgroundImage = newGradientBackImg;
    • 字体:this.Font = new Font(GlobalParams.SiemensFontFamily, GlobalParams.FontSize, FontStyle.Bold, GraphicsUnit.Pixel, 1);
    • 边框
      • 清除:this.FlatAppearance.BorderSize = 0;
      • 颜色:this.FlatAppearance.BorderColor = Color.FromArgb(173, 190, 203);
  • 事件/效果
    • 悬停时显示手形鼠标
      • this.btnTabCommonData.Click += new EventHandler(btnTabCommonData_Click);

        private void btn_MouseEnter(object sender, EventArgs e)
        {
        ((Button)sender).Cursor = Cursors.Hand;
        }

          

相关文章