Please enable JavaScript to view this site.

KOL/MCK - User Guide

combobox

 

This window object combines two entities into one: a one-line text box, and the above list of strings. Very often this visual element is also called a "drop-down list", but this is wrong. Now this object is rarely used in the mode when the combo box is exactly the combo box, and the input field with the list is displayed at the same time (that is, the list seems to be "dropped out" forever and not hidden).

 

Most often, combo lists are still made drop-down (due to space saving on the form, probably). But the "simple" combo box mode, when the list is always displayed, still exists and can be used in applications.

 

It goes without saying that only one item can be selected in a combo box at a time. When you select (select) an item from the list, its text is copied to the input field. To add new elements, you need to call the Add and Insert methods in your code (the elements themselves are never automatically added to the list, including when they are entered into the input field, when it can be edited).

 

One small (but not insignificant) detail. An object of this type (when it is just a drop-down list) should not try to "align" (Align) so that its height tries to automatically adjust to the parent's height (or the height remaining on the parent window). That is, the styles caLeft, caRight, and caClient are undesirable. The problem might be that there will be a conflict between the system and the alignment code. In the worst case, the application will freeze trying to align an object that refuses to change its height, in the best case, the change in height will simply be rejected. The ways I know of to change the height of the input field for the combi-list is to change the font in it, or to use the OnMeasureItem event and the coOwnerDrawVariable style (see below).

 

There is a little more to know about the combo box. Unlike the vast majority of other window objects, a combo box does not allow you to dynamically change its parent (i.e. the window it is on). You can't just take and assign another object as Parent. The combined list receives a parent once, and will not be able to leave him for another until his death. (Generally speaking, changing the parent for a control dynamically is difficult to call a frequently requested feature, but you never know what cases happen).

 

Constructor:

NewComboBox(Parent, Options); Combi-list options are largely correlated with simple list options, but there are also special ones:

 

coReadOnly - read only, refers to the input field, prohibits entering text here (an element can only be selected from the available list);

coNoHScroll - horizontal scrolling is prohibited, the option refers to the list of elements (if there are elements with too wide text, the text will be cut off, and it will never be possible to read it to the end if the user cannot dynamically increase the width of the list);

coAlwaysVScroll - always show the vertical scroll bar (even if the number of elements is small enough to show them all without using scrolling);

coLowerCase - the text both in the input field and in the list is displayed in lower case;

coNoIntegralHeight - similar to loNoIntegralHeight for a simple list object, refers to a list;

coOemConvert - for OEM-text (i.e. for text in DOS encoding), conversion to ANSI code is performed;

coSort - the list is always sorted;

coUpperCase - the text is displayed and entered in upper case;

coOwnerDrawFixed and coOwnerDrawVariable - similar to the corresponding options for a simple list, tell the system that the contents of the list will be drawn using an additionally assigned procedure (OnDrawItem event);

coSimple - the style of a "simple" list, in which the list is not drop-down, but constantly lies on the form directly below the input field, forming a single whole with it.

 

 

Properties and methods SelStart, SelLength, CurIndex, Count, Items [], IndexOf, SearchFor, ItemSelected [], ItemData [] - refer specifically to the list part of the combined control. The input field has a Text property (same as Caption). If you need to work with text selection in the input field, you should use the Perform method with the corresponding CB_XXXX window messages.

 

 

Properties common to the entire combo box:

 

OnDropDown - this event is triggered before the list is dropped by pressing the F4 button, the Alt + <down arrow> key combination, or by clicking on the button with a triangle to the right of the input field, - for a drop-down combo box. In the handler of this event, it is possible, among other things, even to organize a change in the contents of the list - since it is not yet displayed on the screen, but you should not do that - for the reason that this may take some time, and it is better not to keep the user waiting for a long time, after every mouse click or keystroke;

OnCloseUp - this event is triggered when the drop-down list is closed - for any reason (an element is selected, the window has lost focus, the <Escape> key was pressed, etc.);

DroppedWidth - refers to the drop-down list, allows you to set a different width for it than for the entire window (in pixels);

OnSelChange - the same event as for a simple list, fixes the change of the selected item (with the difference that the combo box does not allow multiple selection, and only one item can be selected - the one that is currently displayed in the text input field);

OnChange - the event of changing the text in the input field, including triggered when the text has changed as a result of selecting another element in the combi-control list part;

AddDirList(s, attrs) - as well as for the list box-list, allows to add a list of files and subdirectories of the specified directory.

 

In MCK, the combo box is represented by the mirrored component TKOLComboBox. Similar to TKOLListBox, the Combobox mirror also has a design-time Items property that allows you to edit the list of strings to initialize the control.

 

 

KOL / MCK User Guide - Created by Carl Peeraer - Diamant Soft, based on the work of Vladimir Kladov - Artwerp.be

  

Keyboard Navigation

F7 for caret browsing
Hold ALT and press letter

This Info: ALT+q
Nav Header: ALT+n
Page Header: ALT+h
Topic Header: ALT+t
Topic Body: ALT+b
Exit Menu/Up: ESC