MSDN上是这么说的:
1. 定位控件类的构造函数。
2. 在构造函数中调用窗体的SetStyle。
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
这将使控件能够支持透明背景色。
3. 在步骤 1 中添加的代码行下再添加下面的代码行。这会将控件的BackColor设置为Transparent。
this.BackColor = Color.Transparent;我都照做了,可是没用。谁知道怎么做吗?谢谢了。
1. 定位控件类的构造函数。
2. 在构造函数中调用窗体的SetStyle。
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
这将使控件能够支持透明背景色。
3. 在步骤 1 中添加的代码行下再添加下面的代码行。这会将控件的BackColor设置为Transparent。
this.BackColor = Color.Transparent;我都照做了,可是没用。谁知道怎么做吗?谢谢了。
例想让RichBox透明是吗?自己重写一个RichTextBoxFriend Class MyRichTextBox
Inherits System.Windows.Forms.RichTextBox Public Sub New()
MyBase.New() '另控件拥有透明色
setstyle(ControlStyles.Opaque, True)
End SubEnd Class
再用 Control.BackgroundBitmap = 此Bitmap即可
1、该控件必需派生自System.Windows.Forms.Control,这说明窗体自身是无法实现的。
2、控件的UserPaint必需设置成true
public partial class u_Connect_Detail : Client.Business.Base.u_DetailBase
{
public u_Connect_Detail()
{
InitializeComponent();
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
} private void beButton3_Click(object sender, EventArgs e)
{
this.BackColor = Color.Transparent;
} }this.BackColor = Color.Transparent; 不能写在构造函数里面。
可以在控件自身的load事件中加入该代码。