We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Inheriting from GridControl causing redundant style settings

I am deriving a class from GridControl. In the constructor for the derived class, I create and add 5 styles to the grid. I also set the AllowSelection property of the grid. When I then add my derived class to a form, all of these styles are auto-generated by the form designer in the InitializeComponent() almost exactly as I have done in the base class. Why is this happening? It''s not causing any problems, it''s just redundant. Is there any way to prevent it? Thanks. Pete Davis

4 Replies

AD Administrator Syncfusion Team April 28, 2004 09:35 AM UTC

Hi Pete, When you make changes in the ctor the BaseStylesMap gets marked modified and therefore all settings will be serialized into code with the designer. To avoid this you should call BaseStylesMap.Modified = false; after you made changes to the BaseStylesMap in your ctor. Code serializtion will then not write out any base styles unless the user made changes to it. Only in the case the user made changes then all settings (also redundant ones) will be written out. Stefan


AD Administrator Syncfusion Team April 28, 2004 12:35 PM UTC

Thanks a ton Stefan. Pete >Hi Pete, > >When you make changes in the ctor the BaseStylesMap gets marked modified and therefore all settings will be serialized into code with the designer. > >To avoid this you should call > >BaseStylesMap.Modified = false; > >after you made changes to the BaseStylesMap in your ctor. > >Code serializtion will then not write out any base styles unless the user made changes to it. Only in the case the user made changes then all settings (also redundant ones) will be written out. > >Stefan >


PD Pete Davis April 28, 2004 04:39 PM UTC

Stefan, Maybe I''m doing this wrong. The last line in the constructor for the class derived from GridControl is: this.BaseStylesMap.Modified = false; As soon as I drop a grid on the form, it re-creates the styles. Did I miss something? Pete


AD Administrator Syncfusion Team April 29, 2004 09:30 AM UTC

I got this to work. I had to remove the grid from the form. Rebuild the project, and then place it back on the form. I had previously rebuilt the project, then removed the grid from the form and added it. I''m not sure why compiling with the grid off the form made the difference. Nevertheless, it works. Thanks. >Stefan, > > Maybe I''m doing this wrong. The last line in the constructor for the class derived from GridControl is: > >this.BaseStylesMap.Modified = false; > > As soon as I drop a grid on the form, it re-creates the styles. Did I miss something? > >Pete >

Loader.
Live Chat Icon For mobile
Up arrow icon