Button的放大与缩小

public Form1()
        {
            InitializeComponent();
            bool enlarged = false;
            button2.MouseEnter += delegate
            {
                if (!enlarged)
                {
                    Rectangle rect = button2.Bounds;
                    rect.Inflate(5, 5);//放大指定量
                    button2.Bounds = rect;
                    enlarged = true;
                }
            };
            button2.MouseLeave += delegate
            {
                if (enlarged)
                {
                    Rectangle rect = button2.Bounds;
                    rect.Inflate(-5, -5);
                    button2.Bounds = rect;
                    enlarged = false;
                }
            };

        }

你可能感兴趣的:(button)