如题

解决方案 »

  1.   

    LZ 直接给Button 的背景添加图片不行吗?LZ想要什么样的效果?
      

  2.   

     button1_Paint  事件中画
    Graphics g = e.Graphics;
      

  3.   

    形状使用Region属性可以控制,绘制放在其Paint事件处理方法中。
      

  4.   

    自己做一个Button1.新建一个UserControl
    2. Protected override void OnPaint(...)
       {
         Graphics g = e.Graphics;//建立画图对象
         GraphicsPath buttonPath = new GraphicsPath(); //自定义Button的形状;
         buttonPath.AddRectange(this.ClientRectange); //矩形Button;
         g.DrawImage((image),ClientRectange); //Image背景;//也可以用渐变色填充
          g.DrawPath(Pens.Black,buttonPath); 
         g.DrawString(.....); 
         ......
       }
       //鼠标事件
       private void MouseClick(...) {...}
       private void MouseEnter(...) {...}
       ......
    3.生成就可以用了.
      

  5.   

    上图中,1-5图分别为素材图和窗体设计时截图,6为运行时效果图下面的代码是通过通过VB2008在线转换成的C#代码Graphics G; 
    Bitmap B_LEFT; 
    Bitmap B_TOP; 
    Bitmap B_BOTTOM; 
    Bitmap B_RIGHT; 
    Bitmap BP; 
    Bitmap B1; 
    Bitmap B_TR; 
    //---------------------------- 
    public void 普通(Button 物件) 

        // ERROR: Not supported in C#: OnErrorStatement 
        物件.FlatStyle = FlatStyle.Flat; 
        物件.BackColor = Color.Transparent; 
        矩形 = new Rectangle(0, 0, 物件.Width, 物件.Height); 
        B1 = new Bitmap(矩形.Width, 矩形.Height); 
        G = Graphics.FromImage(B1); 
        G.DrawImage(My.Resources.button, new Rectangle(0, 0, 10, 13), new Rectangle(1, 0, 10, 13), GraphicsUnit.Pixel); 
        G.DrawImage(My.Resources.button, new Rectangle(0, 矩形.Height - 14, 10, 14), new Rectangle(1, 14, 10, 14), GraphicsUnit.Pixel); 
        G.DrawImage(My.Resources.button, new Rectangle(矩形.Width - 10, 0, 10, 13), new Rectangle(77, 0, 10, 13), GraphicsUnit.Pixel); 
        G.DrawImage(My.Resources.button, new Rectangle(矩形.Width - 10, 矩形.Height - 14, 10, 14), new Rectangle(77, 14, 10, 14), GraphicsUnit.Pixel); 
        G.DrawImage(My.Resources.button, new Rectangle(10, 0, 矩形.Width - 20, 13), new Rectangle(11, 0, 26, 13), GraphicsUnit.Pixel); 
        G.DrawImage(My.Resources.button, new Rectangle(10, 矩形.Height - 14, 矩形.Width - 20, 14), new Rectangle(11, 14, 26, 14), GraphicsUnit.Pixel); 
        G.DrawImage(My.Resources.button, new Rectangle(0, 13, 10, 矩形.Height - 27), new Rectangle(1, 13, 10, 1), GraphicsUnit.Pixel); 
        G.DrawImage(My.Resources.button, new Rectangle(矩形.Width - 10, 13, 10, 矩形.Height - 27), new Rectangle(77, 13, 10, 1), GraphicsUnit.Pixel); 
        G.Dispose(); 
        物件.BackgroundImage = B1; 
        物件.ForeColor = Color.White; 
        物件.FlatAppearance.BorderColor = Color.Transparent; 
        物件.FlatAppearance.BorderSize = 0; 
        物件.FlatAppearance.CheckedBackColor = Color.Transparent; 
        物件.FlatAppearance.MouseDownBackColor = Color.Transparent; 
        物件.FlatAppearance.MouseOverBackColor = Color.Transparent; 

      

  6.   

    http://www.chenjiliang.com/Article/View.aspx?ArticleID=4439