我重写了button的onpain方法后,text无法显示到button上..代码如下
protected override void OnPaint(PaintEventArgs e)



Graphics g=e.Graphics;  
SelfDramImg(g,0); 
                            //如果加下面代码,text就能正常显示.但是OnPaint方法等于没用了..
                           //系统会重修绘制button...不加的话就不能在button上显示文字
//base.OnPaint(e);
}

解决方案 »

  1.   

    已经解决..谢谢,只要再绘制文本就行了..^_^...失误
    Graphics g=e.Graphics;  
    StringFormat drawFormat = new StringFormat();
    drawFormat.FormatFlags = StringFormatFlags.DisplayFormatControl;
    drawFormat.LineAlignment=StringAlignment.Center;
    drawFormat.Alignment=System.Drawing.StringAlignment.Center;  
    g.DrawString(this.Text,this.Font,new LinearGradientBrush(this.ClientRectangle,Color.Black,Color.Black,LinearGradientMode.Vertical),this.ClientRectangle,drawFormat);      
      

  2.   

    恭喜楼主,我还在为重写个textbox发愁呢