private void Container_Paint(object sender, PaintEventArgs e)
{
//e.Graphics.TranslateTransform(printersContainer.AutoScrollPosition.X, printersContainer.AutoScrollPosition.Y);
Pen printerBorderPen = new Pen(ColorCode.BorderForm, 3);
foreach (Control c in this.Controls)
{
if (c is ucPrinterControl)
{
Graphics graphics = c.CreateGraphics();
graphics.DrawRectangle(printerBorderPen, e.ClipRectangle.Left, e.ClipRectangle.Top, e.ClipRectangle.Width - 1, e.ClipRectangle.Height - 1);
}
}
Pen formBorderPen = new Pen(ColorCode.BorderForm, 3);
e.Graphics.DrawRectangle(formBorderPen, new Rectangle(0, 0, Container.Width, Container.Height));
}
As seen in the code above I use Graphics to draw rectangular widgets in the UI application that I am creating. When I use auto scrolling the widgets that were previously not visible (under the current view) get viewed but displayed as empty. Same happens when I scroll u again. But when I minimize and unminimize the window it all gets appeared in the current view.
As seen on the above code I used TranslateTransform
but it didn't solve the problem.