MSDN上是这么说的:
1. 定位控件类的构造函数。 
2. 在构造函数中调用窗体的SetStyle。
  SetStyle(ControlStyles.SupportsTransparentBackColor, true);
这将使控件能够支持透明背景色。
3. 在步骤 1 中添加的代码行下再添加下面的代码行。这会将控件的BackColor设置为Transparent。
  this.BackColor = Color.Transparent;我都照做了,可是没用。谁知道怎么做吗?谢谢了。

解决方案 »

  1.   

    重写控件
    例想让RichBox透明是吗?自己重写一个RichTextBoxFriend Class MyRichTextBox
        Inherits System.Windows.Forms.RichTextBox    Public Sub New()
            MyBase.New()        '另控件拥有透明色
            setstyle(ControlStyles.Opaque, True)
        End SubEnd Class
      

  2.   

    我也是看例子的,刚才试了一下,好像不行,换控件添加到窗体后并没有像窗体那样的Opaque属性,不知道为什么。
      

  3.   

    先定义一个Bitmap,用Bitmap.makeTransparent方法使其透明,
    再用 Control.BackgroundBitmap = 此Bitmap即可
      

  4.   

    有几个条件:
    1、该控件必需派生自System.Windows.Forms.Control,这说明窗体自身是无法实现的。
    2、控件的UserPaint必需设置成true
      

  5.   

    我刚才测试过了,对于自定义的用户对象是可以的。代码如下:
    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事件中加入该代码。