this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
语句注释掉,因为从Button控件不可能有自动缩放功能,它必须依赖于其父控件。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
namespace TestCrystalButton
{
public partial class CrystalButton : Button
{
public CrystalButton()
{
InitializeComponent();
}
private enum MouseActionType
{
None,
Hover,
Click
}
private MouseActionType mouseAction;
private GraphicsPath GetGraphicsPath(Rectangle rc, int r)

本文介绍如何在C# WinForm应用程序中创建具有水晶效果的按钮。通过自定义GraphicsPath和使用渐变刷,实现了按钮的阴影、渐变色以及文字居中显示,从而达到美观的效果。

1960





