【问题标题】:C# Custom textBox designC# 自定义文本框设计
【发布时间】:2015-03-16 11:39:34
【问题描述】:

我想在 C# 中自定义一个文本框,但遇到了问题。如果我设置

 textBox1.BackColor = Color.Transparent 

我收到错误:

Additional information: Control does not support transparent background colors.

我尝试在构造函数中插入

SetStyle(ControlStyles.SupportsTransparentBackColor, true); 

但没有解决任何问题。我已经安装了 Dev Express,但我不知道它是否有帮助。一些想法? 构造函数:

public Constructor()
        {
            this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            InitializeComponent();
        }

【问题讨论】:

  • C# transparency on textbox 的可能重复项
  • 不是重复的,我已经看到了
  • 所以你的问题是为什么我的子类文本框忽略了透明度?显示构造函数

标签: c# colors textbox


【解决方案1】:

这是一个重复的问题吗??

Why am I getting "Control does not support transparent background colors"?

我认为 winform 不支持透明背景色。

【讨论】:

  • 您到底想达到什么目的?透明文本框控件的目的是什么??
  • 只是为了设计。我想要它有边框并且没有背景颜色
  • 必须有解决方案 您为什么这么认为?也许没有! - 你可以从头开始写一个,但TextBox 是一个相当不友好的野兽,不适合重新设计..
  • 我知道你想要它。你为什么需要它?您想在文本框中显示什么内容吗?您是否希望用户能够看到其背后的文本或图像。你只是想强制 windows/UI/whatever 做一些它不会做的事情?我不想多管闲事。我试图理解你的目的。给猫剥皮的方法总是不止一种。问题是为什么
  • 我是这么说的,因为Transparent 选项不是没有的。它有一个作用。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-09-05
  • 1970-01-01
  • 1970-01-01
  • 2013-07-15
  • 2013-03-02
  • 2013-06-29
相关资源
最近更新 更多