Connecting Tech Pros Worldwide Forums | Help | Site Map

How do I prevent appearance inheritance?

Fred Flintstone
Guest
 
Posts: n/a
#1: Nov 20 '05
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!


Herfried K. Wagner [MVP]
Guest
 
Posts: n/a
#2: Nov 20 '05

re: How do I prevent appearance inheritance?


* Fred Flintstone <idontthinkso@nospam.com> scripsit:[color=blue]
> 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.[/color]

Inside the control, you can use 'Me.DesignMode' to check if the control
runs in design mode.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Chris Dunaway
Guest
 
Posts: n/a
#3: Nov 20 '05

re: How do I prevent appearance inheritance?


On Tue, 22 Jun 2004 12:50:36 -0400, Fred Flintstone wrote:
[color=blue]
> I have an overridden panel control with a gradient background and 3D[/color]

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.
Fred Flintstone
Guest
 
Posts: n/a
#4: Nov 20 '05

re: How do I prevent appearance inheritance?


How does that disable visual inheritance?


On 22 Jun 2004 20:13:54 +0200, hirf-spam-me-here@gmx.at (Herfried K.
Wagner [MVP]) wrote:
[color=blue]
>* Fred Flintstone <idontthinkso@nospam.com> scripsit:[color=green]
>> 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.[/color]
>
>Inside the control, you can use 'Me.DesignMode' to check if the control
>runs in design mode.[/color]

Fred Flintstone
Guest
 
Posts: n/a
#5: Nov 20 '05

re: How do I prevent appearance inheritance?


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:
[color=blue]
>On Tue, 22 Jun 2004 12:50:36 -0400, Fred Flintstone wrote:
>[color=green]
>> I have an overridden panel control with a gradient background and 3D[/color]
>
>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,[/color]

Closed Thread