Documents
NextGrid & NextDBGrid
- Upgrade existing projects for loading changes
- Edit events in NextGrid
- NextGrid Vista Style
- NextGrid How To
- Integrating Inplace Editors
- NextGrid Slide Style Tutorial
- InputLine Tutorial
- FieldChooser Tutorial
- Using Editors in runtime
- Grid Report Tutorial
- Html Column Tutorial
NextGrid
- NextGrid Quick Start
- Custom Draw in NextGrid
- Export to XML from NextGrid
- Optimize NextGrid
- NextGrid Custom Sorting
- VirtualColumn Tutorial
- Graphic Column Tutorial
- TreeColumn Tutorial
NextDBGrid
- NextDBGrid Quick Start
- NextDBGrid Events
- NextDBGrid How To
- Sorting records in NextDBGrid
- LookupColumn Tutorial
NextInspector
- NextInspector Advanced tutorial
- ToolbarItem tutorial
- NextDBInspector Tutorial
- NextInspector Item Types
- Map VCL property to item
- NextInspector Quick Start
NextSheet
NextCollection
- NxInfoPanel Tutorial
- Vista Styled Panels
- NxPathControl and NxNotebook tutorial
- NxPathControl Quick Start
- NxFlipPanel and NxHeaderPanel Quick Start
- NxOutlookBar Tutorial
- NxPageControl and NxNotebook Quick Start
- NxButton Tutorial
- NxAlertWindow Tutorial
Misc
- Numeric FormatMask
- NxVirtualDataSet tutorial
- DateTime FormatMask
- NxPreview Quick Start
- 32bit Bitmaps Tutorial
- Quick update
- Enable typing unicode characters in InplaceEditors
- Using NxColorScheme
- NxProgress Tutorial
- NxAutoCompletion Tutorial
- Component Names Change
- NxComboBox styles
Labs
NextGrid .NET
NxAutoCompletion Tutorial
Related Articles:
Info
- Skill:
- Version: 1.0.0
- Author: Wim van der Vegt
- Created: 2008-07-22
- Updated: 2008-07-22
Downloads
Introducing NxAutocompletion
Autocompletion is a feature used often in windows. For instance the address bars of both explorer and internet explorer and the start|run dialog feature autocompletion. Besides the GUI handling of the autocompletion, Windows knows a number of sources for autocompletion suggestions. By choosing the appropriate sources one can tap into the history or file and folder names.

NxAutoCompletion brings this feature into the Next Suite.
NxAutoCompletion works quite simple, associate an NxAutoCompletion component with a TWinControl descendant control and selected from which sources windows has to supply suggestions for autocompletion. There are only a few options that have to do with appearance.
Available TNxAutoCompletion Sources are:
| Name | Meaning |
|---|---|
| asShell | Shell, i.e. files and folder names. |
| asHistory | History folder. |
| asMRU | Most recently run programs. |
| asList | Custom list of strings defined by the Strings property. |
Multiple sources are allowed but keep in mind the option can be slow for all except the asList option as the registry has to be accessed to retrieve the values!
Most interesting source for programs is perhaps the asList where a TStrings property called Strings can be used to store suggestion values for autocompletion.
Options property:
| Name | Meaning |
|---|---|
| aoAutoAppend | Automatically append text. |
| aoAutoSuggest | Use a dropdown box as seen in the Start|Run dialog. |
| aoUseArrowKey | Use arrow keys to navigate through the suggestions. |
Using NxAutoCompletion
There are three basic ways of using the NxAutoCompletion.
Associate a single TNxAutoCompletion component with a single TWinControl component.
Use a design time created TNxAutoCompletion for multiple TWinControl components.
Use a runtime created TNxAutoCompletion for one or more TWinControl components.
If NxAutoCompletion is used to supply autocompletion for a single component, it’s enough to associate the controls in the object inspector and customize the settings of the NxAutoCompletion component. No programming is required.
The result looks like (note that the entries shown are originating from the Strings property):

If NxAutoCompletion should be used with multiple components, one can either switch the associated control to whatever is in edit mode but it’s also possible to create a TNxAutoCompletion on the fly at runtime.
In the following code a TNxAutoCompletion object is created and associated with TNxEdit called NxEdit1 when editing starts.
procedure TForm1.NxEdit1Enter(Sender: TObject);
begin
if not Assigned(NxAutoCompletion2) then
begin
NxAutoCompletion2 := TNxAutoCompletion.Create(Self);
NxAutoCompletion2.Sources := [asList, asShell, asHistory, asMRU];
NxAutoCompletion2.Strings.Add('aaaa');
NxAutoCompletion2.Strings.Add('aabb');
end;
if (NxAutoCompletion2.Associate <> TNxEdit(Sender)) then
begin
NxAutoCompletion2.Associate := TNxEdit(Sender);
NxAutoCompletion2.Enabled := True;
end;
end;
When we want to enable autocompletion for a TNextGrid cells we can use the following code (in case we dropped a TNxAutoCompletion component onto the form):
procedure TForm1.NextGrid1Edit(Sender: TObject; ACol, ARow: Integer; Value:
WideString);
Begin
if Assigned(TNextGrid(Sender).InplaceEdit)
and (NxAutoCompletion1.Associate <> TNextGrid(Sender).InplaceEdit)
then NxAutoCompletion1.Associate := TNextGrid(Sender).InplaceEdit;
End;
procedure TForm1.NextGrid1AfterEdit(Sender: TObject; ACol, ARow: Integer; Value:
WideString);
begin
NxAutoCompletion1.Associate := nil;
end;
It’s also possible to combine autocompletion with a dynamically created TNxAutoCompletion as is seen in the following code:
procedure TForm1.NextGrid1Edit(Sender: TObject; ACol, ARow: Integer; Value:
WideString);
Begin
if not Assigned(NxAutoCompletion2) then
begin
NxAutoCompletion2 := TNxAutoCompletion.Create(Self);
NxAutoCompletion2.Sources := [asList, asShell, asHistory, asMRU];
NxAutoCompletion2.Strings.Add('aaaa');
NxAutoCompletion2.Strings.Add('aabb');
end;
if Assigned(TNextGrid(Sender).InplaceEdit) and
(NxAutoCompletion2.Associate <> TNextGrid(Sender).InplaceEdit) then
begin
NxAutoCompletion2.Associate := TNextGrid(Sender).InplaceEdit;
NxAutoCompletion2.Enabled := True;
end;
end;
procedure TForm1.NextGrid1AfterEdit(Sender: TObject; ACol, ARow: Integer; Value:
WideString);
begin
if Assigned(NxAutoCompletion2) then FreeAndNil(NxAutoCompletion2);
end;
The result looks like (Note that Entries from the History List are shown):

Note: currently there is no support for settings the root folder from which the asShell provider should start supply suggestions.