Click here to Skip to main content
15,886,137 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to add a custom attribute to a custom button control like Items attribute of ListBox Control so that user can add item to custom button control using designer editor.
C#
public List<string> LstOfValues = new List<string>();

        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public List<string> Items
        {
            get { return LstOfValues; }
            set {
                LstOfValues.Clear();
                foreach (string s in value)
                {
                    LstOfValues.Add(s);
                }
            }
        }


i have added above code to my custom button control and an attribute named Items added to property window but when i want to add any item to this using design editor i have got an error saying "Constructor on type 'System.String' not found".

thanks in advance
Posted

1 solution

That's a job for a custom UITypeEditor[^]. See the link for an example on building an editor for your custom object that works with .NET's PropertyEditor.
 
Share this answer
 
Comments
Maciej Los 14-May-13 16:53pm    
+5
Ibrahim Adham 15-May-13 8:22am    
thanks lukeer for your great solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900