I need your help in following question (using .Net 3.5 and Windows Forms):
I just simply want to draw a line on a middle of a combobox (Windows Forms) that is situated on a form.
The code I use is:
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));
}
To fire a paint event:
private void button1_Click(object sender, EventArgs e)
{
comboBox1.Refresh();
}
When I execute the code and press button the line isn't drawn. In debug the breakpoint at the paint handler isn't being hit. The strange thing is that on MSDN there is a paint event in ComBox's events list, but in VS 2010 IntelliSense doesn't find such event in ComboBox's members
Thanks.