By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,398 Members | 1,404 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,398 IT Pros & Developers. It's quick & easy.

How to apply a gradient to a textbox?

P: n/a
I'm making a custom control that has a multiline textbox on it. I want to
make the textbox have a gradient background. On my custom control's Paint
event I call a routine that draws a gradient on the textbox's background,
but the gradient starts appearing at the bottom of the textbox after the
last line of text. It's almost as if VB draws the gradient on the entire
textbox, then blanks out the part of the textbox that actually displays text
with a solid color background, leaving the gradient on the rest of the
textbox after the last line of text.

I use the following code to create this "half-finished" gradient effect:
Graphics.FromHwnd(TextBox.Handle).FillRectangle( _
New Drawing2D.LinearGradientBrush( _
TextBox.ClientRectangle, _
Color1, _
Color2, _
Drawing2D.LinearGradientMode.Horizontal), _
Maybe I shouldn't be using the ClientRectangle property of the textbox? Is
it even possible to do what I want to do (which basically amounts to a text
on a non-solid background)?

And, no, I can't use a label, unless you can put scrollbars on a label.

- Don
Nov 20 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.