文本框与透明背景 [英] TextBox with a Transparent Background

查看:133
本文介绍了文本框与透明背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要做的textBox透明背景C#.NET Visual Studio是犯了一个错误,如果你定义属性

I want to do textBox a Transparent Background c# .net Visual Studio is making a mistake if you define Properties

推荐答案

在构造函数将这个:

SetStyle(ControlStyles.SupportsTransparentBackColor, true);

类需要启用透明的风格。 (出于某种原因,默认情况下不支持)。

The class need to enable the transparent style. (For some reason it isn't supported by default).

public class MyControl : System.Windows.Forms.UserControl
{
        public MyControl ()
        {
            // Create visual controls
            InitializeComponent();
            SetStyle(ControlStyles.SupportsTransparentBackColor, true);
        }
}

或者,如果它不是一个自定义的控制:

Or if it's not a custom control:

mycontrolObject.SetStyle(ControlStyles.SupportsTransparentBackColor, true);

更多关于 Control.SetStyle方法

其他控件样式

这篇关于文本框与透明背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆