470,632 Members | 1,983 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,632 developers. It's quick & easy.

Make inherited property invisible

Hi all,

I have made a usercontrol and I want to prevent the ContextMenuStrip
property from being available, how can I do this?

I have tried stuff like
Protected Shadows ContextMenuStrip as Object

But I can always still see the property in the designer, can anyone help me
out with this?

Kind regards,

Martin.
Dec 22 '06 #1
5 1694
How about Private instead of Protected?
"Martin" <@ntlworld.comwrote in message
news:_0*******************@newsfe4-gui.ntli.net...
Hi all,

I have made a usercontrol and I want to prevent the ContextMenuStrip
property from being available, how can I do this?

I have tried stuff like
Protected Shadows ContextMenuStrip as Object

But I can always still see the property in the designer, can anyone help
me out with this?

Kind regards,

Martin.


Dec 22 '06 #2
No that doesn't work either, I had already tried it.

here is an example:

Public Class Class1
Inherits ListView

Private Shadows ContextMenuStrip As Object

<System.ComponentModel.Browsable(False)_
Private Shadows Property Forecolor() As Color
Get
End Get
Set(ByVal value As Color)
End Set
End Property

<System.ComponentModel.Browsable(False)_
Private Shadows FullRowSelect As Object
End Class

All 3 overridden properties still show up in the designer, is there any way
around this?

Thanks.
"Scott M." <s-***@nospam.nospamwrote in message
news:Or**************@TK2MSFTNGP06.phx.gbl...
How about Private instead of Protected?
"Martin" <@ntlworld.comwrote in message
news:_0*******************@newsfe4-gui.ntli.net...
>Hi all,

I have made a usercontrol and I want to prevent the ContextMenuStrip
property from being available, how can I do this?

I have tried stuff like
Protected Shadows ContextMenuStrip as Object

But I can always still see the property in the designer, can anyone help
me out with this?

Kind regards,

Martin.



Dec 22 '06 #3
Hi all,

I'm still trying to figure this out with no success yet.

I've created a user control that contains a listview; To work as I want it
to, it relies on the the columns and contextmenu being set up in a
particular way, and I would therefore like to prevent consumers of my
control from accessing those properties directly.

So far I have been unable to find a way of hiding/overriding these
properties in the visual design environment.

Could anyone at least tell me that it can't be done, in which case I'll be
disappointed, but at least I can stop wasting anymore time on this aspect of
the design.

Sorry to keep on about this, but I was hoping someone could at least give me
a definitive answer one way or the other.

Kind regards,

Martin.
Dec 22 '06 #4
Martin wrote:
I have made a usercontrol and I want to prevent the ContextMenuStrip
property from being available, how can I do this?

I have tried stuff like
Protected Shadows ContextMenuStrip as Object

But I can always still see the property in the designer, can anyone help me
out with this?
To suppress properties in the Designer, use the Browsable attribute, as in

Imports System.ComponentModel

<Browsable(False)_
Protected Shadows ContextMenuStrip as Object

But, this property will still get included in the "Designer Generated"
code. If you're developing this Control over time (i.e. while other
people are developing app's that use it), you might want to prevent
this, especially for new properties. If you don't, and their app's get
"ahead" of your usercontrol, their constructors can fail with
MissingMethodExceptions.
To suppress this code being generated, use the
DesignerSerializationVisiblity attribute, as in

Imports System.ComponentModel

' Sorry about the /ridiculously/ long names!
<Browsable(False),
DesignerSerializationVisibility(DesignerSerializat ionVisibility.Hidden) _
Protected Shadows ContextMenuStrip as Object

HTH,
Phill W.
Dec 22 '06 #5
Phill,

that did the trick, thanks so much!

I also used your example to work out how to stop intellisence from showing
it in the code window like so...

<EditorBrowsable(EditorBrowsableState.Never), Browsable(False),
DesignerSerializationVisibility(DesignerSerializat ionVisibility.Hidden)_
Public Overrides Property ContextMenuStrip() As
System.Windows.Forms.ContextMenuStrip
Get
' My own code
End Get
Set(ByVal value As System.Windows.Forms.ContextMenuStrip)
'My own code
End Set
End Property
Once again, thanks!

"Phill W." <p-.-a-.-w-a-r-d@o-p-e-n-.-a-c-.-u-kwrote in message
news:em**********@south.jnrs.ja.net...
Martin wrote:
>I have made a usercontrol and I want to prevent the ContextMenuStrip
property from being available, how can I do this?

I have tried stuff like
Protected Shadows ContextMenuStrip as Object

But I can always still see the property in the designer, can anyone help
me out with this?

To suppress properties in the Designer, use the Browsable attribute, as in

Imports System.ComponentModel

<Browsable(False)_
Protected Shadows ContextMenuStrip as Object

But, this property will still get included in the "Designer Generated"
code. If you're developing this Control over time (i.e. while other
people are developing app's that use it), you might want to prevent this,
especially for new properties. If you don't, and their app's get "ahead"
of your usercontrol, their constructors can fail with
MissingMethodExceptions.
To suppress this code being generated, use the
DesignerSerializationVisiblity attribute, as in

Imports System.ComponentModel

' Sorry about the /ridiculously/ long names!
<Browsable(False),
DesignerSerializationVisibility(DesignerSerializat ionVisibility.Hidden)>
_
Protected Shadows ContextMenuStrip as Object

HTH,
Phill W.

Dec 22 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Miguel Dias Moura | last post: by
2 posts views Thread by Michael Chong | last post: by
6 posts views Thread by Selden McCabe | last post: by
4 posts views Thread by asad.naeem | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.