ActiveX
To create a custom cell
At run time,
- If your control contains more than one sheet, specify the sheet with which you want to work by setting the Sheet property.
- Add the custom cell with the AddCustomCellType method. Set the name to the name you will use in the TypeCustomName method.
- Set the Col, Col2, Row, and Row2 properties as appropriate.
- If you are selecting a block of cells, set the BlockMode property to True.
- Set the name with TypeCustomName. Set the style value with TypeCustomStyle. This value should specify the window styles for the editor and/or renderer control if you want Spread to create instances of the control for you.
- Set the CellType property to 16 (Custom).
- If you selected a block of cells, set the BlockMode property back to False.
- The custom cell types are dependent on additional code in various events in order to work correctly. If the custom cell supports editing, the CTCreateEditorControl event must create and return an instance of a control to use for editing unless the name of the custom cell type is identical to a window class name previously registered with RegisterClass. Note that this works only for simple Windows control classes registered with RegisterClass, and not with ActiveX controls. To use an ActiveX control as the editor, you must put code in CTCreateEditorControl event to set your control to the EditorControl parameter.
- If the custom cell type uses a renderer control, the CTCreateRendererControl event must create and return an instance of a control to use for rendering unless the name of the custom cell type is identical to a window class name previously registered with RegisterClass. Note that this works only for simple Windows control classes registered with RegisterClass, and not with COM classes or ActiveX controls. To use an ActiveX control as the renderer, you must put code in the CTCreateRendererControl event to set your control to the RendererControl parameter.
- If the custom cell type does not use a renderer control, or if the renderer control does not support the WM_PRINT message, the CTPain tCell event must draw the contents of the cell when the cell is not being edited. If the custom cell type is intended to edit a data type other than string, the CTGetEditorValue event must return the value from the editor control and the CTSetValue event must set the value to the editor control.
- If the custom cell type uses a renderer control and is intended to render a data type other than string, the CTSetValue event must set the value to the renderer control.
- If the custom cell type supports overflow into adjacent cells when the AllowCellOverflow property is true, then the CTGetPreferredSize event must calculate and return the dimensions of the overflow.