Make inherited property invisible

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Martin

    #1

    Make inherited property invisible

    Hi all,

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

    I have tried stuff like
    Protected Shadows ContextMenuStri p as Object

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

    Kind regards,

    Martin.


  • Scott M.

    #2
    Re: Make inherited property invisible

    How about Private instead of Protected?


    "Martin" <@ntlworld.comw rote in message
    news:_0Gih.2015 6$493.12298@new sfe4-gui.ntli.net...
    Hi all,
    >
    I have made a usercontrol and I want to prevent the ContextMenuStri p
    property from being available, how can I do this?
    >
    I have tried stuff like
    Protected Shadows ContextMenuStri p as Object
    >
    But I can always still see the property in the designer, can anyone help
    me out with this?
    >
    Kind regards,
    >
    Martin.
    >
    >

    Comment

    • Martin

      #3
      Re: Make inherited property invisible

      No that doesn't work either, I had already tried it.

      here is an example:

      Public Class Class1
      Inherits ListView

      Private Shadows ContextMenuStri p As Object

      <System.Compone ntModel.Browsab le(False)_
      Private Shadows Property Forecolor() As Color
      Get
      End Get
      Set(ByVal value As Color)
      End Set
      End Property

      <System.Compone ntModel.Browsab le(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-mar@nospam.nosp amwrote in message
      news:Orz7XUWJHH A.1816@TK2MSFTN GP06.phx.gbl...
      How about Private instead of Protected?
      >
      >
      "Martin" <@ntlworld.comw rote in message
      news:_0Gih.2015 6$493.12298@new sfe4-gui.ntli.net...
      >Hi all,
      >>
      >I have made a usercontrol and I want to prevent the ContextMenuStri p
      >property from being available, how can I do this?
      >>
      >I have tried stuff like
      >Protected Shadows ContextMenuStri p as Object
      >>
      >But I can always still see the property in the designer, can anyone help
      >me out with this?
      >>
      >Kind regards,
      >>
      >Martin.
      >>
      >>
      >
      >

      Comment

      • Martin

        #4
        Re: Make inherited property invisible

        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.


        Comment

        • Phill W.

          #5
          Re: Make inherited property invisible

          Martin wrote:
          I have made a usercontrol and I want to prevent the ContextMenuStri p
          property from being available, how can I do this?
          >
          I have tried stuff like
          Protected Shadows ContextMenuStri p 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.Componen tModel

          <Browsable(Fals e)_
          Protected Shadows ContextMenuStri p 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
          MissingMethodEx ceptions.
          To suppress this code being generated, use the
          DesignerSeriali zationVisiblity attribute, as in

          Imports System.Componen tModel

          ' Sorry about the /ridiculously/ long names!
          <Browsable(Fals e),
          DesignerSeriali zationVisibilit y(DesignerSeria lizationVisibil ity.Hidden) _
          Protected Shadows ContextMenuStri p as Object

          HTH,
          Phill W.

          Comment

          • Martin

            #6
            Re: Make inherited property invisible

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

            <EditorBrowsabl e(EditorBrowsab leState.Never), Browsable(False ),
            DesignerSeriali zationVisibilit y(DesignerSeria lizationVisibil ity.Hidden)_
            Public Overrides Property ContextMenuStri p() As
            System.Windows. Forms.ContextMe nuStrip
            Get
            ' My own code
            End Get
            Set(ByVal value As System.Windows. Forms.ContextMe nuStrip)
            '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:emgha4$j0p $1@south.jnrs.j a.net...
            Martin wrote:
            >
            >I have made a usercontrol and I want to prevent the ContextMenuStri p
            >property from being available, how can I do this?
            >>
            >I have tried stuff like
            >Protected Shadows ContextMenuStri p 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.Componen tModel
            >
            <Browsable(Fals e)_
            Protected Shadows ContextMenuStri p 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
            MissingMethodEx ceptions.
            To suppress this code being generated, use the
            DesignerSeriali zationVisiblity attribute, as in
            >
            Imports System.Componen tModel
            >
            ' Sorry about the /ridiculously/ long names!
            <Browsable(Fals e),
            DesignerSeriali zationVisibilit y(DesignerSeria lizationVisibil ity.Hidden)>
            _
            Protected Shadows ContextMenuStri p as Object
            >
            HTH,
            Phill W.

            Comment

            Working...