I have a form which I'm bringing up using ShowDialog
which contains a couple of text boxes, labels and a button. The problem I'm having is that the text boxes are being drawn before the form itself and the other controls are drawn.
I am overriding the OnPaint
method I'm not sure if this could be causing the problem:
protected override void OnPaint(PaintEventArgs e)
{
ControlPaint.DrawBorder(e.Graphics, e.ClipRectangle, Color.Black, ButtonBorderStyle.Solid);
base.OnPaint(e);
}
It's only a slight delay but it's visible and annoying. Thank you.
The form is double buffered by the way.
EDIT: I have pinpointed the issue to be the fact that the form does not have a FormBorderStyle
. With the FormBorderStyle
set to Sizable
, this issue does not occur. However please note that having FormBorderStyle.None
as my border style is necessary, so I have not found a solution yet.
Try adding this to the dialog box form:
protected override CreateParams CreateParams
{
get
{
// Activate double buffering at the form level. All child controls will be double buffered as well.
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x02000000; // WS_EX_COMPOSITED
return cp;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With