Click here to Skip to main content
15,924,317 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
See more:
There was many very articles talking about creating a gradient button. However, i know some softwares have the special textbox control and it's very nice (like: Nokia PC Suite, or like this http://4.bp.blogspot.com/_DsTN2TagWBQ/THAffzWqbRI/AAAAAAAAAGo/b1_XaGW16uc/s320/myfinal.gif. Any body know how drawing textbox like this? I'm a beginner and i need study about this.

Thanks all
Posted
Updated 9-May-11 11:54am
v2
Comments
AspDotNetDev 9-May-11 23:32pm    
FYI, I deleted your answer. If you would like to comment on an answer, each answer has an "Add Comment" link below it.
AspDotNetDev 9-May-11 23:52pm    
FYI, I just updated one of my solutions with extra info.

The closest thing I could find for doing this in GDI+ is this: Owner-drawing a Windows.Forms TextBox. However, I think interop with WPF would be your best bet.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 10-May-11 0:06am    
You know, despite my criticism against "90%" of works, I learned from some which are really impressive. This is not closest.

Please see my answer.
--SA
AspDotNetDev 10-May-11 0:45am    
I am not sure what you are saying here. Could you elaborate?
Sergey Alexandrovich Kryukov 10-May-11 1:16am    
Forget it. I messed up because I did not understand question and started to fix my replies...
--SA
Not sure if you are using WPF, ASP.NET, or Windows Forms, but you can do this fairly easily in WPF: http://www.vbdotnetheaven.com/UploadFile/dbeniwal321/WPFTextBox01052009013240AM/WPFTextBox.aspx.

You can also use Interop to get a WPF textbox to appear in a Windows Forms application: http://www.developerfusion.com/community/blog-entry/8393574/wpfwinforms-interop-a-highlighted-textbox/.
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 10-May-11 0:15am    
The problem is in the samples text boxes don't look well. From the programming standpoint, the references are good, my 5. The problem is art, not code.

I also offered WPF solution. I used this method, it works very well.
--SA
AspDotNetDev 10-May-11 0:42am    
The problem the OP is facing is a technical one, not an artistic one.
rinkatori 10-May-11 11:33am    
thanks all, i'm trying drawing a text box control with border, rounded corner, gradient background in C#.net. Can we Draw a text box by using GDI+ ?
I just found another potential solution. Perhaps you could use the AlphaBlendTextBox - A transparent/translucent textbox for .NET and overlay it on top of a gradient image.

There is also this: Alpha Blended (Transparent Capable) TextBox and RichTextBox.

UPDATE: I noticed this message provides a very short way of making a transparent RichTextBox.
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 10-May-11 0:04am    
Frankly, this is a weak idea, from the artistic point of view, it's just nothing. Transparency is given, usually in much more complex designs. Nothing new or even useful.

Will you look at my answer?
--SA
AspDotNetDev 10-May-11 0:44am    
"Transparency is given" -- do you mean that transparency is a given feature that is not difficult to implement in Windows Forms? Have you ever tried to implement transparency of a TextBox in Windows Forms? The problem is that the Windows Forms textbox does not offer transparency and does not use the same graphics pipeline as other controls, so some work must be done to do any sort of custom drawing with TextBox.
Sergey Alexandrovich Kryukov 10-May-11 1:12am    
You're right. Yes, I did it, but -- I forgot it's edited text... Transparency in control (with System.Drawing) is easy when you do it all from scratch, but when derived from control... yes, this is a problem). With WPF it's also easy...
--SA
rinkatori 10-May-11 11:35am    
i read this article but when i make .dll file and import to my project. It seem have a mistake, what's wrong? when i run my project, Debugger noticed me: "BLink carret .....". Why?
AspDotNetDev 10-May-11 12:27pm    
This is a new problem; do not ask the question here. Please ask it as a new question, and include as many details as you can.
The sample you show in you question looks very simple. People do much more sophisticated work.

Most works are done on buttons.
Text box should be pretty simple, not to distract users. Readability is much more important.

First thing you need is some drawing skills. By that reason, for some 90% of developers a good button presents totally unresolvable problem. At least to my eyes (I cannot say my eyes are the eyes of an expert, not at all) most of the button components I see look completely tasteless. I think with text boxes it could be worse; as too busy text background is way too common.

Now, here is my recipe which only works on WPF. Make a vector drawing using the wonderful Open Source vector editor called Inkscape, see http://en.wikipedia.org/wiki/Inkscape[^], http://www.inkscape.org/[^]. It uses Scalable Vector Graphics format (SVG, see http://en.wikipedia.org/wiki/Scalable_Vector_Graphics[^]) but can export to XAML.

Export drawing to XAML and put it in Resource Dictionary. During run-time, you can scale it and use.

—SA
 
Share this answer
 
v2
Comments
AspDotNetDev 10-May-11 0:48am    
This does not answer the OP's question. You may not have noticed the answer posted by the OP that I deleted. The OP would like a solution in GDI+, not in WPF. My initial answer was geared toward WPF because the OP did not indicate the technology he/she is using. The GDI+ requirement is what makes this a difficult question to answer.
Sergey Alexandrovich Kryukov 10-May-11 1:15am    
GDI? Oh, deleted reply! I see now. OK, thank you for the note. Pity :-)
--SA
rinkatori 10-May-11 12:56pm    
thank you, i have made it easilier with XAMP
Sergey Alexandrovich Kryukov 10-May-11 20:59pm    
Do you mean XAML?
You're welcome, thanks for accepting this answer.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900