Hiding properties from the Forms Designer

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

    Hiding properties from the Forms Designer

    (VB.Net 2003)
    I have a UserControl that exposes a number of public properties.

    When using this control on a.n.other Form, how can(?) I prevent
    the Forms Designer from adding code into InitializeCompo nent to
    set any or all of these properties when I save the form?

    There are one or two that I /might/ want set in this way, but I'd like
    to "persuade" the Designer to leave the rest well alone ...

    Any suggestions?
    TIA,
    Phill W.


  • Herfried K. Wagner [MVP]

    #2
    Re: Hiding properties from the Forms Designer

    "Phill. W" <P.A.Ward@o-p-e-n-.-a-c-.-u-k> schrieb:[color=blue]
    > I have a UserControl that exposes a number of public properties.
    >
    > When using this control on a.n.other Form, how can(?) I prevent
    > the Forms Designer from adding code into InitializeCompo nent to
    > set any or all of these properties when I save the form?[/color]

    \\\
    < _
    DesignerSeriali zationVisibilit y( _
    DesignerSeriali zationVisibilit y.Hidden _
    ) _[color=blue]
    > _[/color]
    Public Property...
    ///

    --
    M S Herfried K. Wagner
    M V P <URL:http://dotnet.mvps.org/>
    V B <URL:http://classicvb.org/petition/>

    Comment

    • Ken Tucker [MVP]

      #3
      Re: Hiding properties from the Forms Designer

      Hi,



      Ken
      --------------------
      "Phill. W" <P.A.Ward@o-p-e-n-.-a-c-.-u-k> wrote in message
      news:dhdu7m$qlb $1@yarrow.open. ac.uk...[color=blue]
      > (VB.Net 2003)
      > I have a UserControl that exposes a number of public properties.
      >
      > When using this control on a.n.other Form, how can(?) I prevent
      > the Forms Designer from adding code into InitializeCompo nent to
      > set any or all of these properties when I save the form?
      >
      > There are one or two that I /might/ want set in this way, but I'd like
      > to "persuade" the Designer to leave the rest well alone ...
      >
      > Any suggestions?
      > TIA,
      > Phill W.
      >
      >[/color]


      Comment

      • Bob Powell [MVP]

        #4
        Re: Hiding properties from the Forms Designer

        There are several ways to do this. People will often refer to the
        BrowsableAttrib ute and override of the relavent properties. This however is
        an inefficient and incorrect way to do things.

        At design time, the IDE provides for the dedicated control designer assigned
        to your component to filter the properties and events so that they are not
        seen by the IDE. This is accomplished using the
        ControlDesigner .PreFilterPrope rties and ControlDesigner PostFilterPrope rties
        methods. Furthermore, if you use reflection or indeed the PropertyGrid at
        runtime you can create custom filters by having your class implement the
        ICustomTypeDesc riptor interface. This enables you to return an edited or
        even augmented list of properties, events and attributes seen by the
        reflection API's

        Of course, at runtime the properties will still be available but if the
        properties are filtered at design time they will not be visible to the code
        serializer. IMO it's simpler to provide a designer with a property filter
        than override N number of properties and mess with their browsability.

        --
        Bob Powell [MVP]
        Visual C#, System.Drawing

        Ramuseco Limited .NET consulting


        Find great Windows Forms articles in Windows Forms Tips and Tricks


        Answer those GDI+ questions with the GDI+ FAQ


        All new articles provide code in C# and VB.NET.
        Subscribe to the RSS feeds provided and never miss a new article.





        "Phill. W" <P.A.Ward@o-p-e-n-.-a-c-.-u-k> wrote in message
        news:dhdu7m$qlb $1@yarrow.open. ac.uk...[color=blue]
        > (VB.Net 2003)
        > I have a UserControl that exposes a number of public properties.
        >
        > When using this control on a.n.other Form, how can(?) I prevent
        > the Forms Designer from adding code into InitializeCompo nent to
        > set any or all of these properties when I save the form?
        >
        > There are one or two that I /might/ want set in this way, but I'd like
        > to "persuade" the Designer to leave the rest well alone ...
        >
        > Any suggestions?
        > TIA,
        > Phill W.
        >
        >[/color]


        Comment

        Working...