Make inherited property invisible

M

Martin

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.
 
M

Martin

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.
 
M

Martin

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.
 
P

Phill W.

Martin said:
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(DesignerSerializationVisibility.Hidden)> _
Protected Shadows ContextMenuStrip as Object

HTH,
Phill W.
 
M

Martin

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(DesignerSerializationVisibility.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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top