WinForm怎样做按钮的凸起和凹下效果vs2005(C#)

解决方案 »

  1.   

    FlatStyle属性设为Popup 不过只有当鼠标放在按钮上的时候才显示想要的效果 
    这是什么原因呀?
      

  2.   

    先画好两个图分别是突起和按下效果的,放在你的项目中,然后在按钮的Mouseover事件或者Click时间里添加button.image="图片路径"。。
      

  3.   

    比如我在项目的资源文件“Resource1.resx”里添加了两幅图片Image1和Image2,分别是按钮凸起和凹下的效果。
    开始把按钮的Image属性值设为Image1,
       button1.Image=global::button.Resource1.Image1;
    然后再这个按钮的Mousehover事件里这样写:
       private void button1_MouseHover(object sender, EventArgs e)
            {
                this.button1.Image = global::button.Resource.Image2;
               
            }
      

  4.   

    MouseHover
    MouseDown
    MouseLeave
    事件都用上,就OK了……
      

  5.   

    看过一本书上是这样模拟popup的 平时的时候paint就是画一个黑边白背景的rectangle 鼠标over的时候变成中间白背景 矩形是左边和上边用白色勾边 右边和下边用黑色勾边 就变成呢个popup的效果了
      

  6.   

    有一投机取巧的方法,用CheckBox来做Button。效果请参考下面的代码,可直接编译运行:// Form1.cs
    // compile with csc /t:winexe Form1.csusing System;
    using System.Drawing;
    using System.Windows.Forms;public class Form1 : Form
    {
        public Form1()
        {
            CheckBox checkBox1 = new CheckBox();
            Button button1 = new Button();        checkBox1.Text = "cancel";
            checkBox1.Location = new Point(60, 80);
            checkBox1.Appearance = Appearance.Button;               //<-------
            checkBox1.CheckState = CheckState.Checked;
            checkBox1.Size = new Size(80, 25);
            checkBox1.TextAlign = ContentAlignment.MiddleCenter;
            
            button1.Text = "ok";
            button1.Location = new Point(60,120);
            button1.Size = checkBox1.Size;        this.Controls.Add(checkBox1);
            this.Controls.Add(button1);
        }
        static void Main()
        {
            Application.Run(new Form1());
        }
    }