Hello,
I am trying to make the background of a combobox hatched. I just want to have the Textbox part of the box hatched, not the button or the dropdown list.
I have written the following code, and it works quite well, despite the fact, that it is hatched only for like 100ms and then the combobox appearance is resettet to the normal style.
public class HatchComboBox : System.Windows.Forms.ComboBox
{
private bool _HATCHED = false;
public HatchComboBox()
{
}
public bool HATCHED
{
get
{
return _HATCHED;
}
set
{
_HATCHED = value;
OnPaint(new PaintEventArgs(this.CreateGraphics(), this.ClientRectangle));
}
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
if (HATCHED)
{
Graphics G = e.Graphics;
G.Clear(this.BackColor);
HatchBrush HBrush = new HatchBrush(HatchStyle.BackwardDiagonal, Color.Blue, this.BackColor);
G.FillRectangle(HBrush, 0, 0, this.Width, this.Height);
HBrush.Dispose();
}
}
}
Maybe you know which property I have to deactivate or so...
thanks in advance
What I have tried:
I have tried to use my code above, but as I said -> the combobox refreshes itself and looks like before within like 100ms.