vcl-cxdropdownedit-f19398f3.md
Enumerates user input modes for drop-down editors.
TcxEditDropDownListStyle = (
lsEditFixedList,
lsEditList,
lsFixedList
);
| Name | Description |
|---|---|
lsEditFixedList |
Fixed List Autocomplete Mode. The editor automatically completes user input if it matches one of the values listed in a drop-down window. Users cannot add new values to the list.
|
| lsEditList |
List Edit Mode. Users can add new values to the list displayed in a drop-down window. If user input partially matches one of existing values, the editor autocompletes the input.
|
| lsFixedList |
Fixed List Mode. Direct editor box input is unavailable. Users can only select values in the list displayed in a drop-down window.
|
Combo and lookup combo box editors can allow users to select an option from a fixed list or add new values depending on the active input mode.
The code example in this section does the following:
Tip
If you need to add a user input string as a new combo box item, handle the OnNewLookupDisplayText event.
How to Test this Code Example
Follow the steps below to test this code example in your RAD Studio IDE:
object cxGrid1: TcxGrid
Left = 72
Top = 80
Width = 545
Height = 200
TabOrder = 0
object cxGrid1DBTableView1: TcxGridDBTableView
Navigator.Buttons.CustomButtons = <>
ScrollbarAnnotations.CustomAnnotations = <>
DataController.DataSource = DataSource1
DataController.Summary.DefaultGroupSummaryItems = <>
DataController.Summary.FooterSummaryItems = <>
DataController.Summary.SummaryGroups = <>
object cxGrid1DBTableView1RecId: TcxGridDBColumn
DataBinding.FieldName = 'RecId'
Visible = False
end
object cxGrid1DBTableView1Groups: TcxGridDBColumn
DataBinding.FieldName = 'Groups'
end
object cxGrid1DBTableView1Names: TcxGridDBColumn
DataBinding.FieldName = 'Names'
end
object cxGrid1DBTableView1Values: TcxGridDBColumn
DataBinding.FieldName = 'Values'
Width = 54
end
end
object cxGrid1Level1: TcxGridLevel
GridView = cxGrid1DBTableView1
end
end
object dxMemData1: TdxMemData
Active = True
Indexes = <>
Persistent.Data = {
5665728FC2F5285C8FFE3F04000000140000000100070047726F757073001400
0000010006004E616D657300040000000300070056616C756573000400000009
000600446174657300010600000047726F75703101050000004E616D6531010A
000000017B000B00010600000047726F75703101050000004E616D6532011400
000001CF0E0B00010600000047726F75703201050000004E616D6533011E0000
00017A210B00010600000047726F75703201050000004E616D65340128000000
01892B0B00}
SortOptions = []
Left = 520
Top = 88
object dxMemData1Groups: TStringField
FieldName = 'Groups'
end
object dxMemData1Names: TStringField
FieldName = 'Names'
end
object dxMemData1Values: TIntegerField
FieldName = 'Values'
end
object dxMemData1Dates: TDateField
FieldName = 'Dates'
end
end
object DataSource1: TDataSource
DataSet = dxMemData1
Left = 472
Top = 176
end
uses
cxDropDownEdit; // Declares the TcxComboBoxProperties class
// ...
procedure TMyForm.FormCreate(Sender: TObject);
var
AProperties: TcxComboBoxProperties;
begin
// Assign a combo box as an in-place editor for the "Names" grid column
cxGrid1DBTableView1Names.PropertiesClass := TcxComboBoxProperties;
AProperties := cxGrid1DBTableView1Names.Properties as TcxComboBoxProperties;
AProperties.BeginUpdate; // Initiates the following batch operation
try
AProperties.Sorted := True; // Sorts prepopulated values
AProperties.DropDownListStyle := lsFixedList; // Limits user input to the prepoulated list
AProperties.DropDownAutoWidth := False; // Disables automatic menu width adjustment
AProperties.DropDownWidth := 105; // Sets a fixed drop-down menu width
// Populate the combo box editor's drop-down menu from the "Names" dataset field
dxMemData1.DisableControls;
try
dxMemData1.First;
while not dxMemData1.Eof do
begin
AProperties.Items.Add(dxMemData1.FieldByName('Names').AsString);
dxMemData1.Next;
end;
dxMemData1.First;
finally
dxMemData1.EnableControls;
end;
finally
AProperties.EndUpdate; // Calls EndUpdate regardless of the batch operation's success
end;
end;
#include "cxDropDownEdit.hpp" // Declares the TcxComboBoxProperties class
// Add the following linker directive to the corresponding CPP source file:
#pragma link "cxDropDownEdit" // Required to use cxDropDownEdit declarations
void __fastcall TMyForm::FormCreate(TObject *Sender)
{
TcxComboBoxProperties *AProperties;
// Assign a combo box as an in-place editor for the "Names" grid column
cxGrid1DBTableView1Names->PropertiesClass = __classid(TcxComboBoxProperties);
AProperties = dynamic_cast<TcxComboBoxProperties*>(cxGrid1DBTableView1Names->Properties);
AProperties->BeginUpdate(); // Initiates the following batch operation
try
{
AProperties->Sorted = true; // Sorts prepopulated values
AProperties->DropDownListStyle = lsFixedList; // Limits user input to the prepopulated list
AProperties->DropDownAutoWidth = false; // Disables automatic menu width adjustment
AProperties->DropDownWIdth = 105; // Sets a fixed drop-down menu width
// Populate the combo box editor's drop-down menu from the "Names" dataset field
dxMemData1->DisableControls();
try
{
dxMemData1->First;
do
{
AProperties->Items->Add(dxMemData1->FieldByName("Names")->AsString);
dxMemData1->Next();
} while(!dxMemData1->Eof);
}
__finally
{
dxMemData1->EnableControls();
}
}
__finally
{
AProperties->EndUpdate(); // Calls EndUpdate regardless of the batch operation's success
}
}
The following properties reference the TcxEditDropDownListStyle type:
TcxCustomColorComboBoxProperties.DropDownListStyleSpecifies the color combo box behavior during text input.TcxCustomComboBoxProperties.DropDownListStyleSpecifies the active user input mode.TcxCustomLookupEditProperties.DropDownListStyleSpecifies the lookup editor’s behavior during text input. See Also