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.
| 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 ;)
|
|
| |
| |
| 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]
|
|
| |
| |
| 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]
|
|
| |
| |
| 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]
|
|
| |
| |
| 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]
|
|
| |
|
|
|
|
|
|
|
|