Thanks for comment.
But actually my problem is not just transparency. While a control is drawing a rectangle on parent form another controls that are added after this are not painted.
My code looks like this
public class MyControl : Panel
{
public MyControl()
{
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
SetStyle(ControlStyles.Opaque, true);
this.SetStyle( ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint ,true);
}
protected override void OnPaint(PaintEventArgs e)
{
// Draw some graphics on this object
// Graphics g= e.Graphics
// ...................
if (IsSMoving)
{
Graphics g2 = this.Parent.CreateGraphics();
// g2.DrawRectangle(); Here we draw a temporary rectangle on parent (Form)
this.Parent.Invoke();
}
base.OnPaint(e);
}
}
}
____________________________
On a form I add some objects from this class. But if a control is moving the ones added later are not shown until it stops moving.