如何在C#中将RichTextBox的背景色设置为透明

穆罕默德·纳西尔·汗(Muhammad Nasir Khan)

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

梅迪·卡德姆鲁(Mehdi Khademloo)
    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();
        }
    }

答案是这样的: 在此处输入图片说明

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何在React Native中将视图的背景色设置为透明

如何将面板的背景色设置为透明

C#透明标签,如何继承背景色

如何在Xaml C#中设置所有窗口的背景色?

如何在Windows Phone 8.1中将图标和背景色设置为Combox项

将背景色设置为透明CSS

无法将标签的背景色设置为透明

如何在反应导航抽屉中将背景色更改为透明

如何在C#中更改kryptontabcontrol的背景色?

如何在Flutter中将FloatingActionButton的背景设置为透明?

如何将“视图”背景色设置为红色,并且应该透明

如何使用javafx / css和fxml将StackPane节点的背景色设置为透明

如何将弹出式背景色设置为透明

如何在Angular 2材质中将div的背景色设置为主色

如何在 C# 中获取当前的控制台前景色/背景色?

如何在Javascript中获取元素的背景色(设置为RGBA)?

如何在AchartEngine中为两个x网格之间的空间设置背景色

如何在 Angular 中为灯箱设置白色背景色?

如何在CSS中为一个元素设置两种背景色?

如何在导航菜单中为两个元素设置活动背景色

如何将swiftui的背景色设置为lightGray?

如何将内容设置为背景色?

如何将 ScrollContentPresenter 设置为背景色?

如何使用背景色使Div透明

NPOI,XSSFComment c#:无法设置注释的背景色

C# UWP 设置标签页背景色

如何在vscode中更改设置输入背景色?

如何在Java GUI中设置按钮的背景色?

如何在UIStackView内设置UIView的背景色?