You may have a Microsoft Windows Form with a user control
that has the DoubleBuffer control style bit set to TRUE. Or, you may have a Microsoft
Windows Forms control (such as a Button, a PictureBox, a CheckBox, or a Label)
with the DoubleBuffer property that is automatically set. When you set the TransparencyKey property of the Windows Form to the value of the BackColor property, and then run the application, the Form appears
transparent and the control appears in color.
Note The color is set in the BackColor property of the Windows Form.
Note You must have the display Color quality set to
32-bit color mode.
To resolve this problem in a Microsoft Windows application
with a Windows Forms control, follow these steps:
Right-click Label1, and then click
Properties.
In the Properties window, set the
FlatStyle property to System.
On the Debug menu, click
Start.
You may notice that both the Form and the
Windows Forms control are transparent. This problem is mentioned in the "More
Information" section of this article.
To resolve the problem in a Windows application with a user
control, follow these steps:
In Solution Explorer, right-click
UserControl1.vb and then click View
Code.
Replace the existing
SetStyle(ControlStyles.DoubleBuffer,
true)
statement with the following statement:
Visual Basic .NET or Visual Basic 2005 Code
SetStyle(ControlStyles.DoubleBuffer, False)
Visual C# .NET or Visual C# 2005 Code
SetStyle(ControlStyles.DoubleBuffer,false);
On the Debug menu, click
Start.
You may notice that both the Form and the user
control are transparent. This problem is mentioned in the "More Information"
section of this article.
Note Before you start the "Steps to Reproduce the Problem", follow
these steps:
Right-click Desktop, and then click
Properties.
Click the Settings tab.
Make sure
that Color quality is set to Highest (32
bit). Some computers may not support 32-bit color quality because the
color quality depends on the computer video card.
In Microsoft Visual Studio .NET or in Microsoft Visual Studio 2005, create a new Windows
application by using either Visual Basic .NET, Visual Basic 2005, Visual C# 2005, or Visual C# .NET.
By
default, Form1 is created.
From the Toolbox, drag a
Label control to Form1.
Right-click Form1, and then click
Properties.
In the Properties window, select the
BackColor property, and then click the Custom
tab.
Select any color other than white.
In the Properties window, set the
TransparencyKey property to the same value as the
BackColor property.
On the Debug menu, click
Start.
You may see that the form is transparent.
However, the label appears in the color that is set in the BackColor property.
In Visual Studio .NET or ijn Visual Studio 2005, create a new Windows Control Library
by using either Visual Basic .NET, Visual Basic 2005, Visual C# 2005, or Visual C# .NET.
By default,
UserControl1 is created.
On the View menu, click
Code. In the Windows Form Designer generated
code region, add the following statements in the constructor of
UserControl1 after the
On the File menu, point to Add
Project, and then click New Project. Under the
Project Types section, select Visual Basic
Projects. Under the Templates section, select
Windows Application.
Note In Visual Studio 2005, click Visual Basic under Project Types.
By default,
Form1 is created.
From the Toolbox, drag a
UserControl1 control to Form1.
Right-click Form1, and then click
Properties.
In the Properties window, select the
BackColor property, and then click the Custom
tab. Select any color other than white.
In the Properties window, set the
TransparencyKey property to the same value as the BackColor property.
In Solution Explorer, right-click
WindowsApplication1, and then click Set as StartUp
Project.
On the Debug menu, click
Start.
You may see that the form is transparent.
However, the user control appears in the color that is set in the BackColor property.