WPF make textbox text transparent - c#

Im attempting to make textbox text somewhat transparent. I've linked an example picture to help explain what i'm talking about.
So far i've tried to edit the opacity of the text box, however this will cause the entire textbox to become transparent instead of just the text.
What can i use to achieve this?

The .Foreground property of a TextBox is a Brush, Brush has a property called .Opacity. You should be able to do something like this:
someTextBox.Foreground?.Opacity = 0.50;

Related

Custom textbox style

I've made a custom textbox in Photoshop, and I want to apply it. I know, that you can't change the background in Visual Studio, or make it transparent. I've seen a few methods on how to do it, but they weren't very clear.
So I want to ask you - what is the esiest way to change the background of a textbox or make it transparent?
You need to Add a new user control , say CustomTextBox and Put this inside the constructor, which will make it transparent
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
C# transparency on textbox
Not sure about transparency, but changing the background of a text box is simple, check this link:
XAML:
http://www.c-sharpcorner.com/UploadFile/mahesh/XAMLTextBox04092007062405AM/XAMLTextBox.aspx
Also, if working on WinForms; you have the BackColor property that works in the same way:
http://msdn.microsoft.com/en-us/library/s2kh9x59(v=vs.110).aspx
EDIT:
You can do it by using a richtextbox instead... kind of.
http://www.codeproject.com/Articles/4544/Insert-Plain-Text-and-Images-into-RichTextBox-at-R
http://www.codeproject.com/Articles/12135/Inserting-images-into-a-RichTextBox-control-the-OL

C# Windows Forms, painting combobox borders

We need to show our disabled comboboxes as an image. The image has the same height as the standard combobox, but for some reason it cannot override the borders of the combobox.
Instead, it end up looking like this:
We would like them look like this image, i.e. that the image is shown on top of everything - including the combobox borders:
Any ideas?
Thanks.
First of all, what you are trying sounds really dirty - the best way would be, if your ComboBox would just look like your image as soon as you disable it!
If there is really no other way:
Create a PictureBox in front of your ComboBox. Set the image as the PictureBox's image, make it Visible whenever you want to "disable" your ComboBox.
But again, using controls to simulate behaviour you would expect to be part of another control is dirty.
Get the location of you textbox, set it invisible, then a the same location place an imagebox

ToolStrip TextBox Colour

I have set up a ToolStrip in my C# WinForms project and have added a TextBox on it. I'm just curious whether it is normal that the TextBox is barely visible due to the colour of the ToolStrip and TextBox.
I could put a border around it or change the background colour of the TextBox but that just looks odd.
Is there some property which I haven't thought of which I could set to make it stand out more but not look out of place?
Screenshot added:
A very light border would probably be best. if you use the same color as the toolstrip, you won't really notice the border at the bottom, but it will make the top of the search box stand out. you might also want to add a margin around it, or less padding inside of it, so it doesn't fill up the whole hight.

Transparent controls in .NET

I have a problem with:
BackColor = Color.Transparent;
It's not working correctly. I have a form with a blue background, and a picturebox with a picture loaded in it. It's not actually taking what's in the picture, but rather - the form's background color. Please tell me there's a simple way to go around this?
What you see in the following screenshot is a custom usercontrol with it's backColor set to transparent, on top of a picture, in a form with a blue background.
I need the usercontrol to display what's UNDER it, as real transparency, it should be showing the gradient and part of the image.
Try setting the picture box to be the parent of the custom user control.
myControl.Parent = this.myPictureBox;
Try calling "SetStyle(ControlStyles.SupportsTransparentBackColor, true);" on your user control constructor.
more details at: http://msdn.microsoft.com/en-us/library/wk5b13s4(v=vs.90).aspx

Coloring backgorund of richtextbox line in C#

I'm trying to color a specific line's background in a RichTextBox.
I need the line's background to be colored all the way to the end of the right side of the control.
I tried using the SelectionBackColor property, but it colors only until the end of the line.
Does anybody know of a way to do this?
thanks :)
mmm, I believe you cannot do it without some custom painting, because as you said, with RTF formatting you format text so if you do not have text ( chars or white spaces or tabs... ) you cannot reach those parts of the control which are completely empty, unless you do change the whole control background color...
Bit messy, but if you don't want to go ahead with custom painting the control. You could make the textbox transparent, then add an image behind the control which has the line selected. You could then change the Image.Location.Y value on the TextChanged event.
Customizing the stock Windows rich text control is possible, but they didn't make it easy. If I were you, I would do what I did: Purchase a better text control.

Categories

Resources