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

Subclass of GridGroupingControl (3.3.0.0)

Hi, I''m trying to develop a subclass of GGC so I can apply a specific set of defaults to the class. The idea is that every tool we develop using this subclass would have the same look and feel we want to provide. I want the users of the subclass to have the freedom to modify the properties in the designer. At the same time, if the user resets ANY property, I want it to revert back to the defaults I provided for the subclass. Also, if I change the default properties of the subclass, I want the changes to be automatically reflected in users of the subclass, assuming the users did not explicitly override the property setting, but simply took the defaults. This is easy enough for simple properties such as BackColor. I have to make sure I re-implement the property with my own DefaultValue attribute. It gets more complicated when talking about properties such as BaseStyles. I am having several problems with this: - I can''t specify a DefaultValue attribute for BaseStyles, Appearance, or other complex properties (that I am aware of). - When I drop the subclass into another form, the BaseStyles that I specified in the subclass get wiped out. This is because BeginInit() is being called twice for the subclass (once in InitializeComponent of the subclass, once in InitializeComponent of the form using the subclass). - If I fudge my subclass so BeginInit() does not get called twice, the class exceptions during initialization. This is because, when I drop the subclass into a form, it wants to re-apply the same BaseStyles again (once that already were applied in the subclass). - If I take a different approach, and put the GGC inside a UserControl and use that as my subclass, I have the opposite problem. The designer of the form containing the UserControl has no ability to modify the properties or events of the grid, even if I expose the grid through a public property of the UserControl. Any help is appreciated, as I am really stuck at the moment. Thanks, - Jon

4 Replies

AD Administrator Syncfusion Team September 30, 2005 02:48 AM UTC

Hi Jonathan, there are two styles in the GridEngine class that define the default style for all styles in the engine: internal GridTableCellStyleInfo engineDefaultStyle = new GridTableCellStyleInfo(); internal GridTableOptionsStyleInfo engineDefaultTableOptions = new GridTableOptionsStyleInfo(); You would need to use reflection to access them. I can also provide public access to them in future. But there is also even a better place for you I think. The GridTableCellAppearance has a static Default property. Just access it as follows: GridTableCellAppearance.ColumnHeader.Font.Italic = true; Now every column header cell will use these settings as default. They will show up even in the propertygrids at design time as default settings. Stefan


JJ Jonathan Jones September 30, 2005 01:37 PM UTC

Hi Stefan, I tried modifying the default as you suggested, but I keep getting the following exception: - GridTableCellAppearance is Read-only. You must not change the GridCellAppearance.Default object; change the Engine.Appearance object instead. Any ideas? Thanks, - Jon


JJ Jonathan Jones September 30, 2005 02:54 PM UTC

Hi Again, After some digging, I tried to override the CreateEngine() method to get the desired behavior. However, this was not working. I think I found part of the problem. In the source for GGC (GridGroupingControl.cs), in the BeginInit() call, there is a call to the following: initEngine = new GridEngine(); I think this means that any attempt to override the engine factory will fail. Shouldn''t that call be changed to the following: initEngine = CreateEngine(); Thanks, - Jon


AD Administrator Syncfusion Team October 3, 2005 12:48 AM UTC

Jonathan, I am working on a sample for both your question s(also the one with MouseButtons / replacing the MouseControllers). There might a code change be necessary in the grid.grouping source code. Let me get back to you later this week. Stefan >Hi Again, > >After some digging, I tried to override the CreateEngine() method to get the desired behavior. However, this was not working. > >I think I found part of the problem. In the source for GGC (GridGroupingControl.cs), in the BeginInit() call, there is a call to the following: > > initEngine = new GridEngine(); > >I think this means that any attempt to override the engine factory will fail. Shouldn''t that call be changed to the following: > > initEngine = CreateEngine(); > >Thanks, >- Jon

Loader.
Live Chat Icon For mobile
Up arrow icon