Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. contro with custom properties

contro with custom properties

Scheduled Pinned Locked Moved C#
questioncsharpvisual-studio
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Susuko
    wrote on last edited by
    #1

    how can i create a custom control with some properties i can see in property visual studio window when i use it inside a form?

    D 1 Reply Last reply
    0
    • S Susuko

      how can i create a custom control with some properties i can see in property visual studio window when i use it inside a form?

      D Offline
      D Offline
      DigitalKing
      wrote on last edited by
      #2

      You have to use fields, you cannot just make variables public: This will not work:

      public int MyInteger=1;

      This will:

      private int myInteger=1;

      public int MyInteger
      {
      get
      {
      return myInteger;
      }
      set
      {
      myInteger=value;
      }
      }

      If you want variables to be read only, just omit the set accessor:

      private int myInteger=1;

      public int MyInteger
      {
      get
      {
      return myInteger;
      }
      }

      You can adjust the visible attributes in the property designer:

      private int myInteger=1;

      [Description("A useless number."),Category("Behavior")]
      public int MyInteger
      {
      get
      {
      return myInteger;
      }
      set
      {
      myInteger=value;
      }
      }

      Hope this helps, DigitalKing

      S 1 Reply Last reply
      0
      • D DigitalKing

        You have to use fields, you cannot just make variables public: This will not work:

        public int MyInteger=1;

        This will:

        private int myInteger=1;

        public int MyInteger
        {
        get
        {
        return myInteger;
        }
        set
        {
        myInteger=value;
        }
        }

        If you want variables to be read only, just omit the set accessor:

        private int myInteger=1;

        public int MyInteger
        {
        get
        {
        return myInteger;
        }
        }

        You can adjust the visible attributes in the property designer:

        private int myInteger=1;

        [Description("A useless number."),Category("Behavior")]
        public int MyInteger
        {
        get
        {
        return myInteger;
        }
        set
        {
        myInteger=value;
        }
        }

        Hope this helps, DigitalKing

        S Offline
        S Offline
        Sasuko
        wrote on last edited by
        #3

        big tnx

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups