private void Form_Resize(object sender, System.EventArgs e)
{
SuspendLayout();
// Panel1, and Custom1 are aligned top left as well.
// Panel1 surrounds Custom1 + 1 Pix this is implied below.
// Custom 1 uses GDI+ and has a Scroll bar that may or may not be
visible on the
// right side
// CustomTo*Edge calculated at load time distance from the * to the
Edge of the form.
Custom1.SuspendLayout();
// Keep this constant.
Custom1.Width = ClientRectangle.Width - Custom1.Left -
CustomToRightEdge;
Custom1.Height = ClientRectangle.Height - Custom1.Top -
CustomToBottomEdge;
// Recalculate and .Value member of the scroll bar so the user does
not get confused.
Custom1.RecalcScrollBar ();
panel1.Width = ClientRectangle.Width - panel1.Left - CustomToRightEdge
+ 2;
panel1.Height = ClientRectangle.Height - panel1.Top -
CustomToBottomEdge + 2;
leadsControl1.Invalidate();
leadsControl1.ResumeLayout(true); // If false scroll bar does not
move
ResumeLayout(false);
}
There is also a Custom control that is docked to the left side but it
does not flicker. And a label1 that is aligned to Top, Left that
requires no more complex logic, again it does not flicker. Flickering
is most apparent when resizing along the left edge of the Form.
It is possible to collapse panel1 and custom1 into one control, but it
would require calculating where the scroll bar is. The panel simply
draws a black box around custom1. I have also tried the WM_SETREDRAW
workaround however there is bleeding from what is behind the form while
the user is resizing, but the flicker is gone.