.NETGURU
(No subject)
Messages   Related Types
This message was discovered on microsoft.public.dotnet.general.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

Bruno Silva (VIP)
well i'm trying to create a control that inherits from textbox or richtextbox
to make the background gradient

i use the following code :

CODE
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
MyBase.OnPaint(e)
Dim gbr As LinearGradientBrush = New LinearGradientBrush(New Rectangle(0, 0,
Me.Width, Me.Height), Color.White, Color.Blue, LinearGradientMode.Horizontal)
e.Graphics.FillRectangle(gbr, New Rectangle(0, 0, Me.Width, Me.Height))
End Sub

but this isn't working... the backcolor in both is always white.

can someone help? thanks in advance ;)
Reply to this message...
 
    
Tom Dacon
I don't know about the rich text box, but my understanding is that the
textbox is actually painted by the container it resides in, so the control's
OnPaint method never actually gets called. I believe that there are several
controls that fit into this category; I've seen a list, but the only one I
remember is the TextBox.

Tom Dacon
Dacon Software Consulting

"Bruno Silva" <Bruno Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
> well i'm trying to create a control that inherits from textbox or
richtextbox
[Original message clipped]

Reply to this message...
 
    
Bruno Silva (VIP)
So, you're telling me that with the paint event a can't do anything... but is
there any other way to do what i need?

"Tom Dacon" wrote:

[Original message clipped]

Reply to this message...
 
    
Tom Dacon
One approach would be to develop your text box control as a custom control,
derived from System.Windows.Forms.Control rather than from TextBox or
RichTextBox. You would have to supply through your own code all the
functionality of the TextBox that your application needs, but you would also
get the OnPaintBackground calls that you need. Notice that OnPaintBackground
is the override you should put the gradient code in, not OnPaint
(OnPaintBackground is not called for the TextBox control, either).

This would take a lot of coding, I suppose, but if you really, really need
the gradient background it might be the price you need to pay to get it. I'd
like to think that there was an easier way to do this, and I'll be
interested to see if anyone chimes in with a less labor-intensive approach.

By the way, doesn't the impact on readability of text on a gradient
background bother you? Do you think it might bother your users?

Tom Dacon
Dacon Software Consulting

"Bruno Silva" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
> So, you're telling me that with the paint event a can't do anything... but
is
[Original message clipped]

Reply to this message...
 
    
Bruno Silva (VIP)
well i guess i'll have to do just that...

Well i want to use really smooth colors just when i get focus in the textbox
to help the user to know where he's typing

thanks for your support ;)

"Tom Dacon" wrote:

[Original message clipped]

Reply to this message...
 
 
System.Drawing.Color
System.Drawing.Drawing2D.LinearGradientBrush
System.Drawing.Drawing2D.LinearGradientMode
System.Web.UI.MobileControls.TextBox
System.Web.UI.WebControls.TextBox
System.Windows.Forms.Control
System.Windows.Forms.PaintEventArgs
System.Windows.Forms.RichTextBox
System.Windows.Forms.TextBox




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification