Replied 8 September 2017, 1:06 pm EST
New FpSpread controls are always created with am empty collection of sheets so that the code in the InitializeComponent method can create and add the sheets. When you drop the control on a form at design time, it starts out empty, and the ControlDesigner for FpSpread (which is an internal class) adds a new Sheet to the control in its InitializeNewComponent method override, so that the new control starts out with a default sheet. Then, when the form is serialized to code, the CodeDomSerializer classes for the various classes in the object model for FpSpread (which are also internal classes) render code in the InitializeComponent method that will create and add the sheet(s) to the control.
The easiest way to make a pre-configured template FpSpread is to use the Spread Designer tool to set up the workbook the way you want it, and then save it to XML. Then you can load that XML into new instances of FpSpread at run-time with one line of code.
To do what you describe, making an inherited control that comes up that way initially, would be much harder to do. You could create a ControlDesigner for your subclass, and implement your code to create your default sheet(s) in its InitializeNewComponent method. The hard part is keeping the other design time functionality working -- you would need to also override the other methods in ControlDesigner with code that calls into the FpSpread's ControlDesigner class, and since that is not public, that requires using reflection.
If you do not mind losing all of the Spread's design time functionality, and really want to limit the user so that they cannot change any of the formatting or properties in the FpSpread, then you can create a UserControl that just contains a FpSpread set up the way you want, and make it fill the UserControl. You would need to add whatever properties and methods you want exposed at design time on your UserControl, but you would have control over how the FpSpread gets initialized in a new instance of your UserControl. It would be very simple to make a UserControl containing a FpSpread that has a string property that specifies the path of filename of a Spread XML file to use as a template -- the property set method can call the FpSpread.Open method with that file.