Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在c语言中将richtextbox的背景色设置为透明#_C#_Transparent - Fatal编程技术网

C# 如何在c语言中将richtextbox的背景色设置为透明#

C# 如何在c语言中将richtextbox的背景色设置为透明#,c#,transparent,C#,Transparent,我想在c语言中将richtextbox的背景色设置为透明# 你能帮我吗 这是一个winform应用程序 public class TransparentLabel : RichTextBox { public TransparentLabel() { this.SetStyle(ControlStyles.Opaque, true); this.SetStyle(ControlStyles.Optim

我想在c语言中将richtextbox的背景色设置为透明# 你能帮我吗 这是一个winform应用程序

    public class TransparentLabel : RichTextBox
    {
        public TransparentLabel()
        {
            this.SetStyle(ControlStyles.Opaque, true);
            this.SetStyle(ControlStyles.OptimizedDoubleBuffer, false);
            this.TextChanged += TransparentLabel_TextChanged;
            this.VScroll += TransparentLabel_TextChanged;
            this.HScroll += TransparentLabel_TextChanged;
        }

        void TransparentLabel_TextChanged(object sender, System.EventArgs e)
        {
            this.ForceRefresh();
        }
        protected override CreateParams CreateParams
        {
            get
            {
                CreateParams parms = base.CreateParams;
                parms.ExStyle |= 0x20;  // Turn on WS_EX_TRANSPARENT
                return parms;
            }
        }
        public void ForceRefresh()
        {
            this.UpdateStyles();
        }
    }
答案是这样的:

什么是透明的?RichTextBox不支持透明性是有原因的,因为很难决定在它背后显示什么。它可以位于组件层次结构中的任何位置。为了让它自己绘制,它需要了解树上所有组件的一些信息。你可以通过黑客攻击使其在整个表单中都是透明的,但是你还不清楚你想要实现什么。这不是一个选项,本机Windows控件不支持。它可以在Windows8上运行,但这不是你今天可以指望的。Windows7是新的XP。它可以完全完美地工作。用这个控制你的意思是什么??只是c#中的一个功能,通过在控件中设置样式。你的意思是什么?它没有任何作用(我测试过)。等一下。我必须为这个画一个图像…几乎没有。Winforms控件中根本没有真正的特性。时期如果你不相信我的话,aks Hans或MSDN。它只能是伪造的。