I'm adding a user control as a topmost control inside a form (panel) like this:
var ct = new UcMessage {
Dock = DockStyle.Fill,
Location = new Point(0, 0),
Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right,
Bounds = this.ClientRectangle,
Size = this.ClientSize
};
this.Controls.Add(ct);
ct.BringToFront();
It will work well and will cover the whole form. I'm using this code in User Control Constructor to set transparency:
base.CreateParams.ExStyle |= 0x20;
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
BackColor = Color.FromArgb(0x80, 0xFF, 0xFF, 0xFF);
My form has a background image, after adding the user control as the topmost control, the transparency will work and I can see the form's background image, But there is a problem, I can not see other form's control. It seems all of them will be hidden after adding user control.
Where is the problem and how to solve it?