C#中如何实现文本框背景透明?

hukai1221 2008-09-15 06:17:12
这次准备写一个日志小程序。想实现如qq上面的背景为漂亮图片的信纸功能。但发现textBox似乎不支持背景透明,请教如何重写这个类来实现文本框的背景透明或者有其他办法可以解决这个问题,谢谢!
...全文
11497 76 打赏 收藏 转发到动态 举报
写回复
用AI写文章
76 条回复
切换为时间正序
请发表友善的回复…
发表回复
bo540346664 2012-08-21
  • 打赏
  • 举报
回复
同志们不用纠结了。

private void Form1_Load(object sender, EventArgs e)
{
this.TransparencyKey = this.BackColor;
this.textBox1.BackColor = this.BackColor;
}
.NET4.0版本下测试通过,背景全透明,不知道楼走是不是想要这种效果……
lv_ws 2012-07-21
  • 打赏
  • 举报
回复
纠结中。WinForm下无法实现呀
LeoLiao44 2012-05-23
  • 打赏
  • 举报
回复
楼主你会做了吗?~?~?~~~我正纠结这个控件怎么写~~
shang123yan 2012-05-18
  • 打赏
  • 举报
回复
我的也不可以
a691662 2011-07-28
  • 打赏
  • 举报
回复
mark 22楼牛
编程爱好者L 2010-09-13
  • 打赏
  • 举报
回复
一句话 网页上可以 窗体不可以..
qinweiqw84 2010-08-25
  • 打赏
  • 举报
回复
TextBox1.BackColor = System.Drawing.Color.Transparent;
有个 鬼用,只不过是吧背景色 设置成 和父级背景一样而已;假透明而已。
我后面有其他颜色的,例如文字,控件,一样挡的死死的。
xiaoshu666 2010-07-09
  • 打赏
  • 举报
回复
我靠,我的vs2005里面好像是不行啊!!
以前在picbox中农个透明的label是这么弄的

textbox,这个不知道,
等待!!!!!!!!!!
学习~~~
xiaoshu666 2010-07-09
  • 打赏
  • 举报
回复
在代码里面设置:
TextBox1.parent = this;
TextBox1.BackColor = System.Drawing.Color.Transparent;
flynncode 2010-06-27
  • 打赏
  • 举报
回复
[Quote=引用 55 楼 llxzj60 的回复:]
C# code

private void button4_Click(object sender, System.EventArgs e)
{
// this.BackColor = System.Drawing.Color.Transparent;//透明,windows textbox not surport it……
[/Quote]

虽然没报错。但是无效啊。依然没有透明!
lhqjuan 2010-04-30
  • 打赏
  • 举报
回复
TextBox1.BackColor = System.Drawing.Color.Transparent;
写Page_Load里是可以实现的
lhqjuan 2010-04-30
  • 打赏
  • 举报
回复
补充下,在vs2005里
hukai1221 2008-09-18
  • 打赏
  • 举报
回复
[Quote=引用 59 楼 starts_2000 的回复:]
C# codeusing System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace Controls
{
public class RichEdit50 : RichTextBox
{
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
static extern IntPtr LoadLibrary(string lpFileName);

protected override CreateParams CreateParams

[/Quote]

我按这个方法试了,依然弹出错误:
控件不支持透明的背景色。
隐藏

在 System.ComponentModel.ReflectPropertyDescriptor.SetValue(Object component, Object value)
在 System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeAssignStatement(IDesignerSerializationManager manager, CodeAssignStatement statement)
在 System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager manager, CodeStatement statement)
什么意思?and 为什么?
hukai1221 2008-09-18
  • 打赏
  • 举报
回复
[Quote=引用 58 楼 wikor 的回复:]
引用 56 楼 hukai1221 的回复:
引用 55 楼 llxzj60 的回复:
C# code
private void button4_Click(object sender, System.EventArgs e)
{
// this.BackColor = System.Drawing.Color.Transparent;//透明,windows textbox not surport it
MyTextBox myTextBox = new MyTextBox();
myTextBox.Name = "testBox";
this.panel1.Controls.Add(m…
[/Quote]


我按这个方法试了,依然弹出错误:
控件不支持透明的背景色。
隐藏

在 System.ComponentModel.ReflectPropertyDescriptor.SetValue(Object component, Object value)
在 System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeAssignStatement(IDesignerSerializationManager manager, CodeAssignStatement statement)
在 System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager manager, CodeStatement statement)
什么意思?and 为什么?
starts_2000 2008-09-18
  • 打赏
  • 举报
回复
把你的TextBox 换成用 RichEdit50 定义
wikor 2008-09-17
  • 打赏
  • 举报
回复
[Quote=引用 56 楼 hukai1221 的回复:]
引用 55 楼 llxzj60 的回复:
C# code
private void button4_Click(object sender, System.EventArgs e)
{
// this.BackColor = System.Drawing.Color.Transparent;//透明,windows textbox not surport it
MyTextBox myTextBox = new MyTextBox();
myTextBox.Name = "testBox";
this.panel1.Controls.Add(myTextBox);
myText…
[/Quote]

是可以通过,没有报错!就是没有效果啊
llxzj60 2008-09-17
  • 打赏
  • 举报
回复
[Quote=引用 55 楼 llxzj60 的回复:]
C# code
private void button4_Click(object sender, System.EventArgs e)
{
// this.BackColor = System.Drawing.Color.Transparent;//透明,windows textbox not surport it
MyTextBox myTextBox = new MyTextBox();
myTextBox.Name = "testBox";
this.panel1.Controls.Add(myTextBox);
myTextBox.Text = "133";
myTe…
[/Quote]我试验了一下,确实可以设置了,可是没有效果,背景还是没有透明。为什么??
hukai1221 2008-09-17
  • 打赏
  • 举报
回复
[Quote=引用 55 楼 llxzj60 的回复:]
C# code
private void button4_Click(object sender, System.EventArgs e)
{
// this.BackColor = System.Drawing.Color.Transparent;//透明,windows textbox not surport it
MyTextBox myTextBox = new MyTextBox();
myTextBox.Name = "testBox";
this.panel1.Controls.Add(myTextBox);
myTextBox.Text = "133";
myTe…
[/Quote]

我试验了一下,确实可以设置了,可是没有效果,背景还是没有透明。为什么??
hanyu0528 2008-09-17
  • 打赏
  • 举报
回复
我也试了,我这边的
textBox1.BackColor = System.Drawing.Color.Transparent;
不行~!!提示“控件不支持透明背景色”~!
XP系统,VS2005
  • 打赏
  • 举报
回复
textBox1.BackColor = System.Drawing.Color.Transparent;

XP系统 vs2005 顺利通过。
加载更多回复(55)

110,545

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧