Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Custom control properties are not saved in designer

Posted on 2011-10-06
2
Medium Priority
?
501 Views
Last Modified: 2012-05-12
Hello

I have a class with several custom properties:

    public class ComboBoxColumn : DataGridViewColumn
    {
        [Category("Data"), DescriptionAttribute("My custom propety"), Browsable(true)]
        public BindingSource DataSource
        {
            get;
            set;
        }

        [Category("Data"), DescriptionAttribute("My custom propety"), Browsable(true)]
        public string DisplayMember
        {
            get;
            set;
        }

        [Category("Data"), DescriptionAttribute("My custom propety"), Browsable(true)]
        public string ValueMember
        {
            get;
            set;
        }

        public ComboBoxColumn()
            : base(new ComboBoxCell())
        {
        }

        public override DataGridViewCell CellTemplate
        {
            get
            {
                return base.CellTemplate;
            }
            set
            {
                base.CellTemplate = value;                
            }
        }
    }


I see my attributes in designer, but when I set the value for those properties, close the designer (pressing OK) and then reopened it, values are no longer there - I see only empty fields. Why are my values not saved?

Greetings, Frenky
0
Comment
Question by:AntonioRodrigo
2 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 36923132
Are you talking about displaymember, valuemember properties? Try using a private variable and get set it.
0
 
LVL 26

Accepted Solution

by:
Anurag Thakur earned 2000 total points
ID: 36923153
You will have to use the DesignerSerializationVisibilityAttribute attribute to achieve that functionality
http://msdn.microsoft.com/en-us/library/system.componentmodel.designerserializationvisibilityattribute.aspx
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Screencast - Getting to Know the Pipeline
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month10 days, 23 hours left to enroll

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question