Get Form Designer To Ignore Properties

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • k.mellor@theiet.org

    Get Form Designer To Ignore Properties

    Hi all,

    I am using Visual Studio 2005.

    I have a User Control with the following property

    [Browsable (false) ]
    public String MyProperty
    {
    get { return this.my_propert y_var; }
    set { this.my_propert y_var = value; }
    }


    When I place my User Control on a form I cannot see the property in
    the Property Browser (good), but default code does get generated in
    InitializeConpo nent

    ......////....
    MyControl.MyPro perty = "";
    ......////....

    How can I prevent this?

    I really ask as my properties in my live code are DateTime properties
    and their default values get set to the day/time the form was designed
    and ideally I do no want to set them to DateTime.Now in the Load
    method or similar.

    Thanks in advance.

    Kevin
  • eschneider

    #2
    Re: Get Form Designer To Ignore Properties


    Try this attribute:

    using System.Componen tModel

    [DesignerSeriali zationVisibilit y(DesignerSeria lizationVisibil ity.Hidden)]



    <k.mellor@theie t.orgwrote in message
    news:3c9ac1eb-e2c5-4812-a981-c773ebaefe10@x1 6g2000prn.googl egroups.com...
    Hi all,
    >
    I am using Visual Studio 2005.
    >
    I have a User Control with the following property
    >
    [Browsable (false) ]
    public String MyProperty
    {
    get { return this.my_propert y_var; }
    set { this.my_propert y_var = value; }
    }
    >
    >
    When I place my User Control on a form I cannot see the property in
    the Property Browser (good), but default code does get generated in
    InitializeConpo nent
    >
    .....////....
    MyControl.MyPro perty = "";
    .....////....
    >
    How can I prevent this?
    >
    I really ask as my properties in my live code are DateTime properties
    and their default values get set to the day/time the form was designed
    and ideally I do no want to set them to DateTime.Now in the Load
    method or similar.
    >
    Thanks in advance.
    >
    Kevin

    Comment

    • k.mellor@theiet.org

      #3
      Re: Get Form Designer To Ignore Properties

      Thank you both for your replies.

      [DesignerSeriali zationVisibilit y
      (DesignerSerial izationVisibili ty.Hidden)]

      works perfectly.

      Kevin

      Comment

      Working...