Home All Groups Group Topic Archive Search About

Make inherited property invisible

Author
22 Dec 2006 12:54 AM
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.

Author
22 Dec 2006 1:05 AM
Scott M.
How about Private instead of Protected?


Show quoteHide quote
"Martin" <@ntlworld.com> wrote in message
news:_0Gih.20156$493.12298@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.
>
>
Author
22 Dec 2006 1:33 AM
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.


Show quoteHide quote
"Scott M." <s-mar@nospam.nospam> wrote in message
news:Orz7XUWJHHA.1816@TK2MSFTNGP06.phx.gbl...
> How about Private instead of Protected?
>
>
> "Martin" <@ntlworld.com> wrote in message
> news:_0Gih.20156$493.12298@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.
>>
>>
>
>
Author
22 Dec 2006 11:04 AM
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.
Author
22 Dec 2006 11:59 AM
Phill W.
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(DesignerSerializationVisibility.Hidden)>  _
    Protected Shadows ContextMenuStrip as Object

HTH,
    Phill  W.
Author
22 Dec 2006 12:53 PM
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!

Show quoteHide quote
"Phill W." <p-.-a-.-w-a-r-d@o-p-e-n-.-a-c-.-u-k> wrote in message
news:emgha4$j0p$1@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(DesignerSerializationVisibility.Hidden)>
> _
>    Protected Shadows ContextMenuStrip as Object
>
> HTH,
>    Phill  W.