Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
why some of propertis for work correctly in designtime need to serializing with atrribute [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] until generated in initializationcomponent() a Form, but some do not need(propertie with Types(int,Color,Font,...))?


        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        [System.ComponentModel.TypeConverter(typeof(ExpandableObjectConverter))]
        public DataGridViewColumnCollection GridColumns
        {
            set
            {   
                _GridColumns = value;             // need serializeing
            }

            get
            {
                if (_GridColumns == null)
                    _GridColumns = new DataGridViewColumnCollection(new DataGridView());
                return _GridColumns;
            }

        }

---------------------------------------------------------------------

public int Width
        {
            set
            {   
                _Width = value;                  //Does not need serializeing
            }

            get
            {
                if (_Width == null)
                    _Width = new DataGridViewColumnCollection(new DataGridView());
                return  _Width;
            }

        }
Posted

1 solution

If the type itself already has the Serializable attribute the serializer is called automatically. In your example System.Int32 is a basic type which is serialized by the framework (Serializable attribute defined in the framework). On the other hand DataGridViewColumnCollection doesn't have the attribute defined so you have to manually define the behaviour.
 
Share this answer
 

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