This question already has an answer here:
- Transparency for windows forms textbox 5 answers
I want to do textBox a Transparent Background c# .net Visual Studio is making a mistake if you define Properties
This question already has an answer here:
I want to do textBox a Transparent Background c# .net Visual Studio is making a mistake if you define Properties
I've found a workaround for this problem, which I have on my own. Most of what I've read over here is true. And the approaches "à la"
AlphaBlendTextBox
are way too complex or too time-consuming for some environments, already heavily charged.Assume you have a given background color and a given picture or whatever you want to see through the
RichTextBox
control. This is what I've done (summarized):TransparencyKey
toSystemColors.InactiveBorder
FormBorderStyle
toFormBorderStyle.None
;ControlBox
,MinimizeBox
,MaximizeBox
andShowIcon
tofalse
,TopMost
totrue
,StartPosition
toFormStartPosition.Manual
,SizeGripStyle
toSizeGripStyle.Hide
), so there's no visible form structuresRichTextBox
with the same size of the form and located on its upper, left cornerBackColor
toSystemColors.InactiveBorder
(remember the TransparencyKey?) and itsBorderStyle
to None as wellI can't pretend this approach fits everybody, but it is way simpler than others I've seen and, as long as I can keep it that way, I do prefer the simpler solutions.
Of course, when you close the main form, you must take care of the child form, but this is pretty basic for you, isn't it?
Enjoy!
Put this in the constructor:
The class need to enable the transparent style. (For some reason it isn't supported by default).
Or if it's not a custom control:
More about Control.SetStyle Method
Other Control Styles
This is not an easy task. .Net TextBox control is a wrapper around Win32 Edit control, so you will need to do sub-classing to achieve background transparency.
Take a look at this sample: AlphaBlendTextBox - A transparent/translucent textbox for .NET