![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
A Panel object does not allow DoubleBuffered to be set. Simply creating a new control as below allows one to set that property so it isn't that it can't be done. It's just a little harder. So, why did they set the property (or any property) to Protected? What's the rational? Thanks Class MyPanel Inherits System.Windows.Forms.Panel Public Sub New() MyBase.New() 'The reason for this class: 'The following protected property needed to be set to reduce flicker Me.DoubleBuffered = True End Sub Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) MyBase.Dispose(disposing) End Sub End Class |
#3
| |||
| |||
|
|
I think this was an oversight. Some would call it an unimplemented feature. -- -- Bob Powell [MVP] Visual C#, System.Drawing Ramuseco Limited .NET consulting http://www.ramuseco.com Find great Windows Forms articles in Windows Forms Tips and Tricks http://www.bobpowell.net/tipstricks.htm Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/faqmain.htm All new articles provide code in C# and VB.NET. Subscribe to the RSS feeds provided and never miss a new article. " active" <activeNOSPAM (AT) a-znet (DOT) com> wrote in message news:uIpJhaiqHHA.4420 (AT) TK2MSFTNGP04 (DOT) phx.gbl... A Panel object does not allow DoubleBuffered to be set. Simply creating a new control as below allows one to set that property so it isn't that it can't be done. It's just a little harder. So, why did they set the property (or any property) to Protected? What's the rational? Thanks Class MyPanel Inherits System.Windows.Forms.Panel Public Sub New() MyBase.New() 'The reason for this class: 'The following protected property needed to be set to reduce flicker Me.DoubleBuffered = True End Sub Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) MyBase.Dispose(disposing) End Sub End Class |
#4
| |||
| |||
|
|
I don't think I was clear. The question is why set ANY property to Protected. It's a little harder to change then Public - but only a little harder (as I illustrated below) If the class prohibits inheritance Protected has a real effect, but otherwise Protected and Public are basically the same. "Bob Powell [MVP]" <bob (AT) spamkillerbobpowell (DOT) net> wrote in message news:3890EBA6-7134-4E02-8D0C-897EF955B9FE (AT) microsoft (DOT) com... I think this was an oversight. Some would call it an unimplemented feature. -- -- Bob Powell [MVP] Visual C#, System.Drawing Ramuseco Limited .NET consulting http://www.ramuseco.com Find great Windows Forms articles in Windows Forms Tips and Tricks http://www.bobpowell.net/tipstricks.htm Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/faqmain.htm All new articles provide code in C# and VB.NET. Subscribe to the RSS feeds provided and never miss a new article. " active" <activeNOSPAM (AT) a-znet (DOT) com> wrote in message news:uIpJhaiqHHA.4420 (AT) TK2MSFTNGP04 (DOT) phx.gbl... A Panel object does not allow DoubleBuffered to be set. Simply creating a new control as below allows one to set that property so it isn't that it can't be done. It's just a little harder. So, why did they set the property (or any property) to Protected? What's the rational? Thanks Class MyPanel Inherits System.Windows.Forms.Panel Public Sub New() MyBase.New() 'The reason for this class: 'The following protected property needed to be set to reduce flicker Me.DoubleBuffered = True End Sub Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) MyBase.Dispose(disposing) End Sub End Class |
#5
| |||
| |||
|
|
Well, now you're getting into aspects of architecture, which I can yack on about all day :-) The protected access keyword enforces the rule that class wishing to change or affect certain behaviours of an object must derive from the base class in question. This was obviously a desire of the original design team. -- Bob Powell [MVP] Visual C#, System.Drawing Ramuseco Limited .NET consulting http://www.ramuseco.com Find great Windows Forms articles in Windows Forms Tips and Tricks http://www.bobpowell.net/tipstricks.htm Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/faqmain.htm All new articles provide code in C# and VB.NET. Subscribe to the RSS feeds provided and never miss a new article. " active" <activeNOSPAM (AT) a-znet (DOT) com> wrote in message news:%23Microsoftya8lqHHA.4836 (AT) TK2MSFTNGP05 (DOT) phx.gbl... I don't think I was clear. The question is why set ANY property to Protected. It's a little harder to change then Public - but only a little harder (as I illustrated below) If the class prohibits inheritance Protected has a real effect, but otherwise Protected and Public are basically the same. "Bob Powell [MVP]" <bob (AT) spamkillerbobpowell (DOT) net> wrote in message news:3890EBA6-7134-4E02-8D0C-897EF955B9FE (AT) microsoft (DOT) com... I think this was an oversight. Some would call it an unimplemented feature. -- -- Bob Powell [MVP] Visual C#, System.Drawing Ramuseco Limited .NET consulting http://www.ramuseco.com Find great Windows Forms articles in Windows Forms Tips and Tricks http://www.bobpowell.net/tipstricks.htm Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/faqmain.htm All new articles provide code in C# and VB.NET. Subscribe to the RSS feeds provided and never miss a new article. " active" <activeNOSPAM (AT) a-znet (DOT) com> wrote in message news:uIpJhaiqHHA.4420 (AT) TK2MSFTNGP04 (DOT) phx.gbl... A Panel object does not allow DoubleBuffered to be set. Simply creating a new control as below allows one to set that property so it isn't that it can't be done. It's just a little harder. So, why did they set the property (or any property) to Protected? What's the rational? Thanks Class MyPanel Inherits System.Windows.Forms.Panel Public Sub New() MyBase.New() 'The reason for this class: 'The following protected property needed to be set to reduce flicker Me.DoubleBuffered = True End Sub Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) MyBase.Dispose(disposing) End Sub End Class |
#6
| |||
| |||
|
|
Bob, I think that is the definition. What I'm wondering is, why would you, for example, create a Protected property. You make it slightly more difficult for a user to change that property, but you don't prevent it. (As in my example I make a new class that changes it. I suppose I could make a new class with a public property that sets the Protected one.) There must (I hope) be a rational for doing that. Have you ever created a Protected property? If so why? Thanks "Bob Powell [MVP]" <bob (AT) spamkillerbobpowell (DOT) net> wrote in message news:%23KG0GyArHHA.3284 (AT) TK2MSFTNGP03 (DOT) phx.gbl... Well, now you're getting into aspects of architecture, which I can yack on about all day :-) The protected access keyword enforces the rule that class wishing to change or affect certain behaviours of an object must derive from the base class in question. This was obviously a desire of the original design team. -- Bob Powell [MVP] Visual C#, System.Drawing Ramuseco Limited .NET consulting http://www.ramuseco.com Find great Windows Forms articles in Windows Forms Tips and Tricks http://www.bobpowell.net/tipstricks.htm Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/faqmain.htm All new articles provide code in C# and VB.NET. Subscribe to the RSS feeds provided and never miss a new article. " active" <activeNOSPAM (AT) a-znet (DOT) com> wrote in message news:%23Microsoftya8lqHHA.4836 (AT) TK2MSFTNGP05 (DOT) phx.gbl... I don't think I was clear. The question is why set ANY property to Protected. It's a little harder to change then Public - but only a little harder (as I illustrated below) If the class prohibits inheritance Protected has a real effect, but otherwise Protected and Public are basically the same. "Bob Powell [MVP]" <bob (AT) spamkillerbobpowell (DOT) net> wrote in message news:3890EBA6-7134-4E02-8D0C-897EF955B9FE (AT) microsoft (DOT) com... I think this was an oversight. Some would call it an unimplemented feature. -- -- Bob Powell [MVP] Visual C#, System.Drawing Ramuseco Limited .NET consulting http://www.ramuseco.com Find great Windows Forms articles in Windows Forms Tips and Tricks http://www.bobpowell.net/tipstricks.htm Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/faqmain.htm All new articles provide code in C# and VB.NET. Subscribe to the RSS feeds provided and never miss a new article. " active" <activeNOSPAM (AT) a-znet (DOT) com> wrote in message news:uIpJhaiqHHA.4420 (AT) TK2MSFTNGP04 (DOT) phx.gbl... A Panel object does not allow DoubleBuffered to be set. Simply creating a new control as below allows one to set that property so it isn't that it can't be done. It's just a little harder. So, why did they set the property (or any property) to Protected? What's the rational? Thanks Class MyPanel Inherits System.Windows.Forms.Panel Public Sub New() MyBase.New() 'The reason for this class: 'The following protected property needed to be set to reduce flicker Me.DoubleBuffered = True End Sub Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) MyBase.Dispose(disposing) End Sub End Class |
#7
| |||
| |||
|
#8
| |||
| |||
|
|
Bob When I asked if you ever used Protected that was a mistake on my part since that's not the best way to get the answer I want. (But look how you had to reach to find a situation.) What I'm wondering about, and there is no reason to expect you to be able to get into someone elses mind, is why MS makes some Properties Protected?? Like: Textbox.DefaultMargin Panel.DoubleBuffered Panel.FontHeight... As I said before, I can create a control the inherits a control with Protected properties and add a public property that changes a base control's Protected property. Would I be doing something that I shouldn't? Thanks |
#9
| |||
| |||
|
|
Of course you'd be doing something you shouldn't. You'd be exposing properties that have a design usage with a specific protection to something else entirely. Whatever approach to take you need to question the motives of the original object and see why those properties were protected. Take the example of Panel.DoubleBuffered; If this property were public, you could turn on double buffering. However, as soon as you make a control with a complexity that requires this operation you automatically need to turn off OnPaintBackground so that you don't cause flashing or multiple redraws of the back-buffer. As soon as you do this you need to override but then you just bring along the baggage of Panel. You might as well accept the fact of doing the job properly, creating an object derived directly from Control or ScrollableControl and stop trying to persuade Panel to do stuff it wasn't designed for. -- Bob Powell [MVP] Visual C#, System.Drawing Ramuseco Limited .NET consulting http://www.ramuseco.com Find great Windows Forms articles in Windows Forms Tips and Tricks http://www.bobpowell.net/tipstricks.htm Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/faqmain.htm All new articles provide code in C# and VB.NET. Subscribe to the RSS feeds provided and never miss a new article. active wrote: Bob When I asked if you ever used Protected that was a mistake on my part since that's not the best way to get the answer I want. (But look how you had to reach to find a situation.) What I'm wondering about, and there is no reason to expect you to be able to get into someone elses mind, is why MS makes some Properties Protected?? Like: Textbox.DefaultMargin Panel.DoubleBuffered Panel.FontHeight... As I said before, I can create a control the inherits a control with Protected properties and add a public property that changes a base control's Protected property. Would I be doing something that I shouldn't? Thanks |
#10
| |||
| |||
|
|
I think I understand now. The answer to my question is that those properties can be changed, but changing them may require more knowledge and care then changing the public properties. thanks "Bob Powell [MVP]" <bob (AT) _spamkiller_bobpowell (DOT) net> wrote in message news:upNDgQfrHHA.4804 (AT) TK2MSFTNGP04 (DOT) phx.gbl... Of course you'd be doing something you shouldn't. You'd be exposing properties that have a design usage with a specific protection to something else entirely. Whatever approach to take you need to question the motives of the original object and see why those properties were protected. Take the example of Panel.DoubleBuffered; If this property were public, you could turn on double buffering. However, as soon as you make a control with a complexity that requires this operation you automatically need to turn off OnPaintBackground so that you don't cause flashing or multiple redraws of the back-buffer. As soon as you do this you need to override but then you just bring along the baggage of Panel. You might as well accept the fact of doing the job properly, creating an object derived directly from Control or ScrollableControl and stop trying to persuade Panel to do stuff it wasn't designed for. -- Bob Powell [MVP] Visual C#, System.Drawing Ramuseco Limited .NET consulting http://www.ramuseco.com Find great Windows Forms articles in Windows Forms Tips and Tricks http://www.bobpowell.net/tipstricks.htm Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/faqmain.htm All new articles provide code in C# and VB.NET. Subscribe to the RSS feeds provided and never miss a new article. active wrote: Bob When I asked if you ever used Protected that was a mistake on my part since that's not the best way to get the answer I want. (But look how you had to reach to find a situation.) What I'm wondering about, and there is no reason to expect you to be able to get into someone elses mind, is why MS makes some Properties Protected?? Like: Textbox.DefaultMargin Panel.DoubleBuffered Panel.FontHeight... As I said before, I can create a control the inherits a control with Protected properties and add a public property that changes a base control's Protected property. Would I be doing something that I shouldn't? Thanks |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |