Rediģēt

Kopīgot, izmantojot


How to: Give Your Control a Transparent Background

The background color for most controls can be set to Transparent in the Properties window at design time, or in code in the form's constructor.

Windows Forms controls don't support true transparency. Controls are drawn to the screen in two parts. First, the background is painted, followed by the control's appearance. While you make a control "transparent" by setting the BackColor to Transparent, this actually passes the background painting to the parent control. If the parent control supports the BackgroundImage property, and the property is set, then this image is drawn as the background of the control. If the property isn't supported or isn't set, the BackColor of the parent is used to draw the background of the control.

A better way to think of control "transparency" is to think of it as inheriting the background paint operation of the parent. You can't see other controls under a "transparent" control.

Note

The Button control allows you to set the BackColor to Transparent, but it has no effect on the control.

To give your control a transparent background

See also