473,472 Members | 1,831 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Disable items from an inherited class?

Hi All
I have a custom class that is derived from the PictureBox class. One of the
properties from the PictureBox class is "SizeMode" and in my custom class I
want to disable the user from being able to modify this.

How can I remove this property from my class?

Thanks,
Steve

Apr 26 '07 #1
8 1863

"Steven Garrad" <st******@hot-nospam-mail.comwrote in message
news:08**********************************@microsof t.com...
Hi All
I have a custom class that is derived from the PictureBox class. One of
the properties from the PictureBox class is "SizeMode" and in my custom
class I want to disable the user from being able to modify this.

How can I remove this property from my class?

Thanks,
Steve
One possibility is override.

http://msdn2.microsoft.com/en-us/lib...h3(VS.71).aspx
Apr 26 '07 #2
I've tried to override this, but SizeMode does not appear.

"pvdg42" <pv****@newsgroups.nospamwrote in message
news:#Q*************@TK2MSFTNGP05.phx.gbl...
>
"Steven Garrad" <st******@hot-nospam-mail.comwrote in message
news:08**********************************@microsof t.com...
>Hi All
I have a custom class that is derived from the PictureBox class. One of
the properties from the PictureBox class is "SizeMode" and in my custom
class I want to disable the user from being able to modify this.

How can I remove this property from my class?

Thanks,
Steve

One possibility is override.

http://msdn2.microsoft.com/en-us/lib...h3(VS.71).aspx

Apr 26 '07 #3
Hi,

"pvdg42" <pv****@newsgroups.nospamwrote in message
news:%2***************@TK2MSFTNGP05.phx.gbl...
>
"Steven Garrad" <st******@hot-nospam-mail.comwrote in message
news:08**********************************@microsof t.com...
>Hi All
I have a custom class that is derived from the PictureBox class. One of
the properties from the PictureBox class is "SizeMode" and in my custom
class I want to disable the user from being able to modify this.

How can I remove this property from my class?
SizeMode is not virtual , so you cannot override it
Apr 26 '07 #4
Hi,

"Steven Garrad" <st******@hot-nospam-mail.comwrote in message
news:08**********************************@microsof t.com...
Hi All
I have a custom class that is derived from the PictureBox class. One of
the properties from the PictureBox class is "SizeMode" and in my custom
class I want to disable the user from being able to modify this.

How can I remove this property from my class?
you have to use the "new" keyword to hide the parent implementation:

new public XXXX SizeMode{
I do not remmber that SizeMode returns that's why the XXXX
Apr 26 '07 #5
AJ
In article <eg**************@TK2MSFTNGP04.phx.gbl>, "Ignacio Machin
\( .NET/ C# MVP \)" <machin TA laceupsolutions.comsays...
Hi,

"Steven Garrad" <st******@hot-nospam-mail.comwrote in message
news:08**********************************@microsof t.com...
Hi All
I have a custom class that is derived from the PictureBox class. One of
the properties from the PictureBox class is "SizeMode" and in my custom
class I want to disable the user from being able to modify this.

How can I remove this property from my class?

you have to use the "new" keyword to hide the parent implementation:

new public XXXX SizeMode{
I do not remmber that SizeMode returns that's why the XXXX
... though there's nothing to stop a user casting your class to a
PictureBox, and using the original SizeMode property.

The only way to completely hide it is to encapsulate a PictureBox
internally, rather than deriving from it.
Apr 26 '07 #6
Steven Garrad <st******@hot-nospam-mail.comwrote:
I have a custom class that is derived from the PictureBox class. One of the
properties from the PictureBox class is "SizeMode" and in my custom class I
want to disable the user from being able to modify this.

How can I remove this property from my class?
Doing so would break Liskov's Substitutability Principle. Basically, if
you don't want type X to have all of the same members available as type
Y, you shouldn't derive type X from type Y in the first place.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Apr 26 '07 #7
It's not that I don't want it, but it's that I don't want it to be changed
by the user of the control.
"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP******************@msnews.microsoft.com...
Steven Garrad <st******@hot-nospam-mail.comwrote:
>I have a custom class that is derived from the PictureBox class. One of
the
properties from the PictureBox class is "SizeMode" and in my custom class
I
want to disable the user from being able to modify this.

How can I remove this property from my class?

Doing so would break Liskov's Substitutability Principle. Basically, if
you don't want type X to have all of the same members available as type
Y, you shouldn't derive type X from type Y in the first place.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Apr 26 '07 #8
Steven Garrad <st******@hot-nospam-mail.comwrote:
It's not that I don't want it, but it's that I don't want it to be changed
by the user of the control.
That's the same thing, effectively. You want to stop the user from
treating the control as if it were a normal PictureBox, which is what
Liskov's principle is about.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Apr 26 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: jwsacksteder | last post by:
I want to have a check box that can optionally disable a text input field in the same dialog. I am asking the user to input the start and end of a range and there needs to be a check box to select...
9
by: Eva | last post by:
Hi, I wanted to know how i can enter values into a specific column of a listview. I have tried the following code but this seems to enter all my values into the first column!!! Can anyone...
5
by: Bob Bedford | last post by:
I create checkboxes using datas from a database (with PHP). I store all values in an array, as I must pass this value like a Form value. Now, in some cases, when a checkbox is selected, I must...
0
by: Ian | last post by:
When you add a control to the web form designer in VS.NET, say a label called "InheritanceTestLabel", VS.NET automatically adds the following line to the code-behind. protected new...
1
by: Geroge D. Lake | last post by:
Hi, I need to disable the resizing of a datagrid. I have tried al day and no luck. Any Ideas? Thanks. George.
7
by: OpticTygre | last post by:
If I have a Class "B" that Inherits Class "A", and my application uses class "B", is there a way that I can keep from exposing properties, subs, and events in the Class "A" base class from the...
4
by: SteveKlett | last post by:
I have a subset of form items that I need to perform different operations on (enable/disable, clear values, change style, etc) rather than hard code the IDs or names I would like to recursively...
1
by: =?Utf-8?B?QW5kcmV3?= | last post by:
Hi, friends, I am using C#.net 2005 to create a windows application. It has menu items, such as File, etc. Under File, there are more menu items, such as New Files, Working Files, etc. Under...
5
by: Kevinp | last post by:
I've spent the last four hours Google searching for a way to disable items in a Combobox. I found one example in C++ which I can't get to work and another in C# that I couldn't get to work either....
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.