In the Paint Event:
Private Sub uc3DPanel_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
Dim rec As Rectangle = New Rectangle(3, 3, Me.Width - 6,
Me.Height - 6)
Dim myBrush As Brush = New Drawing2D.LinearGradientBrush(rec,
GradientColor1, GradientColor2, GradientT)
Select Case miDrawstyle
Case 1
ControlPaint.DrawBorder3D(e.Graphics, ClientRectangle,
Border3DStyle.Bump)
Case 2
ControlPaint.DrawBorder3D(e.Graphics, ClientRectangle,
Border3DStyle.Etched)
Case 3
ControlPaint.DrawBorder3D(e.Graphics, ClientRectangle,
Border3DStyle.Flat)
Case 4
ControlPaint.DrawBorder3D(e.Graphics, ClientRectangle,
Border3DStyle.Raised)
Case 5
ControlPaint.DrawBorder3D(e.Graphics, ClientRectangle,
Border3DStyle.RaisedInner)
Case 6
ControlPaint.DrawBorder3D(e.Graphics, ClientRectangle,
Border3DStyle.RaisedOuter)
Case 7
ControlPaint.DrawBorder3D(e.Graphics, ClientRectangle,
Border3DStyle.Sunken)
Case 8
ControlPaint.DrawBorder3D(e.Graphics, ClientRectangle,
Border3DStyle.SunkenInner)
Case 9
ControlPaint.DrawBorder3D(e.Graphics, ClientRectangle,
Border3DStyle.SunkenOuter)
End Select
If UseGradients = True Then
e.Graphics.FillRectangle(myBrush, rec)
End If
myBrush = Nothing
End Sub
I solved the inheritance problem (kind of) by drawing the gradient
last. If I draw the gradient first and then apply the border, every
control placed in the panel has that border. I also had to reduce the
area drawn by the gradient because it would erase the border.
However, it's a nifty accidental feature cause at 3 pixels or more, it
retains the border and allows the true BackColor to come through as a
seondary inside border.
The only real problem left is that in design view, if you change a
color, the change doesn't appear. I have to switch to code view then
back to design to see the change. Don't know why or where to begin
with that one.
I'll post the entire source if I can get this figured out. I'd still
like to know how to disable visual inheritance tho.
Fred.
On Tue, 22 Jun 2004 15:45:41 -0500, Chris Dunaway
<"dunawayc[[at]_lunchmeat_sbcglobal[dot]]net"> wrote:
On Tue, 22 Jun 2004 12:50:36 -0400, Fred Flintstone wrote:
I have an overridden panel control with a gradient background and 3D
I don't have an answer for you, just a related question. When you inherit
from the Panel control, where do you handle the painting to override the
panel? In OnPaint? or in the Paint event? And do you call the
MyBase.OnPaint, or MyBase.Paint? Just trying to understand it
Thanks,