Custom textbox style - c#

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

Related

WPF make textbox text transparent

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;

How to set Custom control as ToolTip for Button or Label?

I have created a custom control of my own and i am in a need of making this custom control as a ToolTip for the Labels or Buttons.
But i could not find a way to set the Custom control as ToolTip.
Anyone please help me on setting the Custom control as ToolTip.
Note:
I don't need solution with showing the Custom Control in mouse_hover events of controls.
Please suggest me ideas to make the custom control as default ToolTip in standard way.
Regards,
Amal Raj
I assume that you already know about overriding the paint event, so I won't go into that. If you want anything a bit more complicated, deriving from the ToolTip control to extend it for your purposes won't make much sense since you'll run into restrictions quite fast.
What you should do is implement your own ToolTip control by reusing some important bits from the original one. If you're feeling adventurous you could follow these steps to get started. I'm going to refer to your custom control as tooltip from now on:
If you want to show custom text or something else for each control that uses your tooltip, you need to implement IExtenderProvider in your class. Here's more about it.
You need to keep track of controls that are using your tooltip and the custom values you've set for them. Internally, Windows Forms tooltip uses a HashTable for that purpose. Key is the control showing your tooltip and value is the tooltip text (or something else you want to tie to your tooltip).
If you want to have more than just one string to show (title, description, image etc), you can have multiple HashTables.
When adding the tooltip to a control, subscribe to mouse events (enter, move, leave) to keep track of when to show the tooltip. If you want to have a delay before showing the control, you need to use an internal timer to keep track of time.
You'll most likely want the tooltip to extend outside the main form's boundaries. You could wrap your tooltip inside a headerless form or an alpha blended form to allow other shapes than rectangle.
Those are the very generalized first steps. In reality, there's quite a bit more to be done. It's been a few years since I implemented my custom ToolTip control so I might be forgetting something crucial. However, if you spend some time poking around the code of Windows Forms's ToolTip class, you'll get quite a good idea of what's going on behind the curtains.
I haven't reviewed the code myself but judging from the ratings, this article will give you a good starting point too: A ToolTip with Title, Multiline Contents, and Image. It's in VB.NET but you can easily convert it to C# by using Telerik's converter or any other.

Label backcolor not going transparent

I've set a label's BackColor property to 'Transparent' in windows form but its just White? It's not going transparent?
Anyone know why this is happening?
The label does not support transparency, you must create your own unique custom control, you can see these code examples.
http://www.codeproject.com/KB/dotnet/transparent_controls_net.aspx
http://www.codeproject.com/KB/vb/uLabelX.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.

Change BackColor of a custom user control to transparent

I am building a custom user control in c#, and the look of the control is an elipse, but the corners of the control can be seen with the default color.
I think that the best way to solve this is making the backcolor of the control transparent, but if i do it in properties doesn't work.
In the control's constructor, try adding a call to SetStyle(ControlStyles.SupportsTransparentBackColor)

Categories

Resources