用GDI+给BUTTON控件绘成色,运行时点BUTTON.按钮并没反应,怎么回事,
如果不给它绘成色,运行时点它.它沉浮一下.....
怎么才能保证它的这个特征不消失呢....真是怪啊......
下面是代码:
private void button1_Paint(object sender, PaintEventArgs e)
{
base.OnPaint (e); Graphics graphics=e.Graphics;
graphics.Clear(Color.Wheat); LinearGradientBrush linGrBrush = new LinearGradientBrush(
new Point(0,0),
new Point(button1.Width,button1.Height),//(button1.Right, button1.Top),
Color.Red,
Color.Blue); graphics.FillRectangle(linGrBrush, 0, 0, button1.Right, button1.Bottom);
///
////下面是打图Button.Text.并使之居中
///
Graphics grfx = e.Graphics;
StringFormat strfmt = new StringFormat(); strfmt.Alignment = StringAlignment.Center;
strfmt.LineAlignment = StringAlignment.Center;
grfx.DrawString("jfdjf",Font,Brushes.White,
button1.Width/2,button1.Height/2,strfmt);
 
}
这代码并不重要,也不出错.关键是点击BUTTON时产生的那个瞬间沉浮特征.怎么才能不消失????