我需要你在下面的(使用.net 3.5和Windows Forms)问题的帮助:绘制的线条上没有一个组合框显示
我只是单纯的想画上一个组合框的中间线(Windows窗体)位于表单上。 我使用的代码为:
void comboBox1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawLine(new Pen(Brushes.DarkBlue),
this.comboBox1.Location.X,
this.comboBox1.Location.Y + (this.comboBox1.Size.Height/2),
this.comboBox1.Location.X + this.comboBox1.Size.Width,
this.comboBox1.Location.Y + (this.comboBox1.Size.Height/2));
}
要发射油漆事件:
private void button1_Click(object sender, EventArgs e)
{
comboBox1.Refresh();
}
当我执行的代码,并按下按钮,则不绘制线条。在调试中,绘制处理程序的断点没有被击中。奇怪的是,在MSDN ComBox的事件列表中有一个绘画事件,但在VS 2010中,IntelliSense在ComboBox的成员中未找到此类事件
谢谢。
我认为你必须重写组合框的OnPaint事件并触发一个画图,你可以调用InvalidateRect – Schwarzie2478 2012-08-08 10:13:28