How do I prevent appearance inheritance?

  • Thread starter Thread starter Fred Flintstone
  • Start date Start date
F

Fred Flintstone

This is THE most annoying feature of VB.Net I've ever seen. *I'LL*
decide what my controls will do and look like, thanks.

I have an overridden panel control with a gradient background and 3D
raised border. Any control I drag into this panel inherits the 3D
border. (like transparent labels)

How do I shut this feature off entirely? It's wasting an incredible
amount of time.

Thanks!
 
* Fred Flintstone said:
This is THE most annoying feature of VB.Net I've ever seen. *I'LL*
decide what my controls will do and look like, thanks.

I have an overridden panel control with a gradient background and 3D
raised border. Any control I drag into this panel inherits the 3D
border. (like transparent labels)

How do I shut this feature off entirely? It's wasting an incredible
amount of time.

Inside the control, you can use 'Me.DesignMode' to check if the control
runs in design mode.
 
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,

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
 
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.
 
Back
Top