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. Windows Forms
  4. properties of user controls

properties of user controls

Scheduled Pinned Locked Moved Windows Forms
csharpquestionvisual-studiowinformsdesign
5 Posts 2 Posters 5 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.
  • A Offline
    A Offline
    abyclassic
    wrote on last edited by
    #1

    Dear All, I am making a Windows Control Library(user control) using VS.NET & C#.NET. Now, i am facing 3 problems: 1.In this control, i wants to remove some of the properties which are available by default to the controls. These properties must be removed from the 'Properties window' of the usercontrol. Also the user must not be able to set these properties using code. I am able to remove the properties from the 'Properties window' by inheriting a class from the System.Windows.Forms.Design.ScrollableControlDesigner & removing the properties by overriding the PreFilterProperties function as show below: protected override void PreFilterProperties(System.Collections.IDictionary properties) { properties.Remove("BackColor"); } But, doing so, this property is available to be set from the code. How can i remove this property fully? 2.I wants to create a property for the control which has sub properties, like the 'Location' property of a button, which has sub properties as 'X, Y & Locked'. My new property for the control must have some subproperties like this. How can i achieve this? 3.I wants to add a property to the user control which allows the user to select a color. When the user selects this property, it must display the same options which are displayed for selecting the color for the satndard properties like 'BackColor'. Then the user must be able to select the required color from these options & the value must be stored in that specific property. Kindly help me to acheieve the above scenarios Best Regards, Abhilash Chandran

    P 2 Replies Last reply
    0
    • A abyclassic

      Dear All, I am making a Windows Control Library(user control) using VS.NET & C#.NET. Now, i am facing 3 problems: 1.In this control, i wants to remove some of the properties which are available by default to the controls. These properties must be removed from the 'Properties window' of the usercontrol. Also the user must not be able to set these properties using code. I am able to remove the properties from the 'Properties window' by inheriting a class from the System.Windows.Forms.Design.ScrollableControlDesigner & removing the properties by overriding the PreFilterProperties function as show below: protected override void PreFilterProperties(System.Collections.IDictionary properties) { properties.Remove("BackColor"); } But, doing so, this property is available to be set from the code. How can i remove this property fully? 2.I wants to create a property for the control which has sub properties, like the 'Location' property of a button, which has sub properties as 'X, Y & Locked'. My new property for the control must have some subproperties like this. How can i achieve this? 3.I wants to add a property to the user control which allows the user to select a color. When the user selects this property, it must display the same options which are displayed for selecting the color for the satndard properties like 'BackColor'. Then the user must be able to select the required color from these options & the value must be stored in that specific property. Kindly help me to acheieve the above scenarios Best Regards, Abhilash Chandran

      P Offline
      P Offline
      PandemoniumPasha
      wrote on last edited by
      #2

      hi, well it seems that you have partly solved question 1. you could also use the attribute: [Browsable(false)] on the properties that you don't wan't to show. i don't know how to remove the property completely, but you could override the existing property and disable the set part. question 2 : don't know:( question3: you can add new properties that you want with the right data type if you wanted to set the 'BackColor' property you could do: [Browsable(true)] public override Color BackColor { get{return this.bkColor;/*or base.BackColor; or any color*/} set{this.bkColor=value;/*or base.BackColor=value; or what ever ...*/} } hope this helps

      regards :)

      A 1 Reply Last reply
      0
      • A abyclassic

        Dear All, I am making a Windows Control Library(user control) using VS.NET & C#.NET. Now, i am facing 3 problems: 1.In this control, i wants to remove some of the properties which are available by default to the controls. These properties must be removed from the 'Properties window' of the usercontrol. Also the user must not be able to set these properties using code. I am able to remove the properties from the 'Properties window' by inheriting a class from the System.Windows.Forms.Design.ScrollableControlDesigner & removing the properties by overriding the PreFilterProperties function as show below: protected override void PreFilterProperties(System.Collections.IDictionary properties) { properties.Remove("BackColor"); } But, doing so, this property is available to be set from the code. How can i remove this property fully? 2.I wants to create a property for the control which has sub properties, like the 'Location' property of a button, which has sub properties as 'X, Y & Locked'. My new property for the control must have some subproperties like this. How can i achieve this? 3.I wants to add a property to the user control which allows the user to select a color. When the user selects this property, it must display the same options which are displayed for selecting the color for the satndard properties like 'BackColor'. Then the user must be able to select the required color from these options & the value must be stored in that specific property. Kindly help me to acheieve the above scenarios Best Regards, Abhilash Chandran

        P Offline
        P Offline
        PandemoniumPasha
        wrote on last edited by
        #3

        hi again, for question 2: have a look at : http://www.thescripts.com/forum/thread576786.html[^]

        regards :)

        1 Reply Last reply
        0
        • P PandemoniumPasha

          hi, well it seems that you have partly solved question 1. you could also use the attribute: [Browsable(false)] on the properties that you don't wan't to show. i don't know how to remove the property completely, but you could override the existing property and disable the set part. question 2 : don't know:( question3: you can add new properties that you want with the right data type if you wanted to set the 'BackColor' property you could do: [Browsable(true)] public override Color BackColor { get{return this.bkColor;/*or base.BackColor; or any color*/} set{this.bkColor=value;/*or base.BackColor=value; or what ever ...*/} } hope this helps

          regards :)

          A Offline
          A Offline
          abyclassic
          wrote on last edited by
          #4

          Hi. thank you for the information. i will try that.. But the 3rd requirement is slightly different than wht u have mentioned. I will make it more clear. For eg: i am making a user control. I adds a property called MyColor to it, which accepts a color as the value. Now, when i uses this control in allications, the properties window for the control displays the MyColor property When the user clicks to select the value for the myColor prperty, the color pallate must be prompted to the user from where he can select the color, like the color pallates displayed to select the color for BackColor property. is there any method to achieve it. Kindly help me Best Regards, Abhilash Chandran

          P 1 Reply Last reply
          0
          • A abyclassic

            Hi. thank you for the information. i will try that.. But the 3rd requirement is slightly different than wht u have mentioned. I will make it more clear. For eg: i am making a user control. I adds a property called MyColor to it, which accepts a color as the value. Now, when i uses this control in allications, the properties window for the control displays the MyColor property When the user clicks to select the value for the myColor prperty, the color pallate must be prompted to the user from where he can select the color, like the color pallates displayed to select the color for BackColor property. is there any method to achieve it. Kindly help me Best Regards, Abhilash Chandran

            P Offline
            P Offline
            PandemoniumPasha
            wrote on last edited by
            #5

            hi, so, it seems that you want to create your own property. it isn't that hard. try this: private Color _myColor;/*this will be your private member to store the color*/ [Browsable(true),Description("This property will set myColor")]/*this is not required*/ public Color MyColor { get{return _myColor;} set { _myColor=value; this.Invalidate();/*this causes the control to repaint so new changes are visible right away*/ } } if you do this, you will have access to _myColor and when used in VS, the property tab will display the color that the user can select from. hope this helps

            regards :)

            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