ComponentOne Query 8.0
Custom Editing

If you are not satisfied with the default editors, you can implement your own editors as shown in the SAMPLES directory and in the C1QueryUI user control in the USERCTL directory.

Custom editors can be defined on a field-by-field basis. You can use different controls (editors) for different fields. This is done dynamically, in special events, so it can even depend on the properties of a particular item being edited.

A custom editor is an ActiveX or intrinsic control residing in the same form with the C1QueryFrame control. It is usually invisible at run time, made visible only when it is activated. A custom editor must always be a single control. If you need multiple controls (for example, an edit box with a spin button), put them in a container control and use the container as your custom editor. There is also a restriction that custom editor controls must be window controls, so windowless controls, such as Label, cannot be used as custom editors.

To implement custom editing, you need to handle the following events: BeforeEdit, ShowCustomEditor, EndEdit, HideCustomEditor.

In the BeforeEdit event, indicate that this item uses custom editing (if this is the case), setting the ShowCustomEditor argument to True, and specify the dimensions of your custom editor setting the ControlWidth and ControlHeight arguments. Deciding which custom editor to use, you can examine the Field argument for data type (Field.Type) and other properties. To convert Field.Type to a variant data type, use the VarTypeFromDataType method.

In the ShowCustomEditor event, assign the control object and the control window handle to the ControlObj and ControlHWND arguments, initialize the editor control with the current value and text using the Value and ValueText arguments, and, finally, show the editor control (set it’s Visible property to True). You don’t have to move the control, C1QueryFrame will automatically position it for in-place editing.

In the EndEdit event, that will be triggered when the user exits the editor, set the Value argument to the current value entered in the control by the user. Set the ValueText argument to the string representation of the value. Whatever you set ValueText to, will be shown in the query as the text of the constant, without affecting the actual value of the constant. You can use this to display the value with formatting required by your users (note that this feature of the EndEdit event is applicable in all cases, not only in custom editing).

Finally, in the HideCustomEditor event, hide the editor control setting its Visible property to False.

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback