Draws the background of the parent of a specified control that supports visual styles.
Call this method first when drawing a control that has a transparent background. That way, if the control is placed on a tab page, rebar, or another control that has a special themed background, it will draw the background properly.
Calling this method when visual styles are not enabled or not supported by the operating system has no effect.
If the background color of the control is not SystemColors.Control or SystemColors.Transparent, the background is filled with the background color of the control instead. You can force the background to be drawn transparently by using the other overload of DrawBackground.
This example overrides the OnPaint method of a Control that has a transparent background. When visual styles are enabled, the background is drawn using the Theme API. Otherwise, the background is cleared to the background color of the control. The transparent background will draw correctly on tab pages, rebars, or other controls that have specifed themed backgrounds.
protected override void OnPaint(PaintEventArgs e) { if (ThemeInformation.VisualStylesEnabled) { ThemePaint.DrawBackground(e.Graphics, this, e.ClipRectangle); } else { using (Brush brush = new SolidBrush(this.BackColor)) { e.Graphics.FillRectangle(brush, e.ClipRectangle); } } }
ThemePaint Class | Skybound.VisualStyles Namespace | ThemePaint.DrawBackground Overload List