Hi guys,

New to this place, so hi to all!

OK, I am also new to C# so please excuse my n00b like questions.

So, my first question;

I am writing a kind of Notepad alternative. I want to have the ability to have the Textbox opacity set to 0, while still being able to see the text being typed.

My reason for this, is I run a pretty lo-rez monitor (my eyesight is bad) and sometimes I need to copy text from one place to another, so I figured I would code something that could see the text under neath the current window, to cross reference.

Is there any way to make just the back ground of a Textbox totally invisible like this, while still having the text appear as normal?

Any help would be great!

As I learn more, I will try to pass on my newly acquired wisdom onto other new starters.

Cheers!

Recommended Answers

All 10 Replies

Sorry to disappoint you, but the Control class does not support a transparant backgound. And as the Textbox control derives from it...

OK, I agree that you can't change the opacity of a textbox. That makes sense, because it resides on a form. If you could change it it would just disappear on the form itself. The Form.Opacity Property allows you to change the visability of the whole form. Instead I suggest looking into the Form.TransparencyKey property. Now you set the background color of the Textbox and the background can disappear.

no you cant do this with set these properties...

The TextBox class dosn't support the Transparent
But I think you can get the same Effect by setting the backColor property for the textbox into the same color for form and ste the text box border to none

textBox1.BackColor =  this.BackColor;

The TextBox class dosn't support the Transparent
But I think you can get the same Effect by setting the backColor property for the textbox into the same color for form and ste the text box border to none

textBox1.BackColor =  this.BackColor;

How could that get the same effect? The default backcolor is NOT transparent. This works for me:

using System;
using System.Windows.Forms;
public class TransparentText : Form
{
	private TextBox Trans_tbx ;
	public static void Main(){Application.Run(new TransparentText());}
	public TransparentText(){
		Trans_tbx = new TextBox ();
		InitializeObjects();
		ResumeLayout(false);
	}
	private void InitializeObjects() {
	this.SuspendLayout();
        this.Trans_tbx.BackColor = System.Drawing.SystemColors.InactiveBorder;
        this.Trans_tbx.Location = new System.Drawing.Point(56, 48);
        this.Trans_tbx.Multiline = true;
        this.Trans_tbx.Name = "Trans_tbx";
        this.Trans_tbx.Size = new System.Drawing.Size(440, 400);
        this.Trans_tbx.TabIndex = 0;
        this.Trans_tbx.Text = "test 1";
        this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
        this.ClientSize = new System.Drawing.Size(544, 502);
        this.Controls.Add(this.Trans_tbx);
        this.Name = "TransparentText";
        this.Text = "test Transparent Text";
        this.TransparencyKey = System.Drawing.SystemColors.InactiveBorder;
	}
}
commented: This helped a lot, thanks! +0

Note if you set the transparent key (Last line of my code example.) to the Form's back color then they would both be transparent.

This worked for me, however I need something slightly different. I was wondering if it is possible to make the textbox transparent so the rest of the form that is under it can be seen, not the desktop or other programs.

this.TransparencyKey = System.Drawing.SystemColors.InactiveBorder;
this line in the constructor solveds any transparency window problem.
thanks

"I need to copy text from one place to another" Just to be sure, you meant TYPE a copy of the text. Others have addressed that.
If you want to copy to the clipboard and paste to your textbox, you MUST lose focus of your application, put focus on the other app, it must support copy to clipboard, then you must go back to your app to paste it. Textboxes implicitly support copy from clipboard. Note that reading the screen may get messy because the typing could interlap. Your alternate text source won't let you see the text in your app if it has focus and wasn't written by you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.