Skip to main content

TcxNewLookupDisplayTextEvent Type

The procedural type for new lookup text processing events.

Declaration

TcxNewLookupDisplayTextEvent = procedure(Sender: TObject; const AText: TCaption) of object;

Parameters

Name Type Description
Sender TObject

Provides access to the editor (a terminal TcxCustomEdit class descendant) that raised the new lookup text processing event.

You need to cast this parameter value to the corresponding editor class to access all public API members.

Tip

Call the Sender.ClassType function or use other RTTI functionality to identify the actual editor type.

AText TCaption

Returns the newly added lookup text string.

You can use the editor’s Properties.LookupItems property to access and manage all lookup text strings.

Remarks

A text box-based editor raises a lookup text processing event every time a user successfully enters a text string that does not match one of the existing lookup text strings.

Code Example: Add and Post a New Combo Box Value to the Bound Dataset Field

The code example in this section applies the following changes to an in-place combo box editor of the Names column in a data-aware Data Grid View:

  • Adds a new combo box item if a user enters a string that does not match any existing combo box item.
  • Creates a new record and sets the custom text entry as a value of the new cell in the Names column.
How to Test this Code Example

Follow the steps below to test this code example in your RAD Studio IDE:

  1. Copy the DFM code snippet below.
  2. Create a new project in the IDE and focus an empty form.
  3. Press Ctrl+V to populate the form with preconfigured components.
  4. Select the Names column and expand the Properties node in the Events tab of the Object Inspector.
  5. Create an empty OnNewLookupDisplayText event handler, paste the code example, and run the project.
  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'
       PropertiesClassName = 'TcxComboBoxProperties'
       Properties.Items.Strings = (
         'Name1'
         'Name2'
         'Name3'
         'Name4')
     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
procedure TMyForm.ComboBox(
  Sender: TObject; const AText: TCaption);
var
  AProperties: TcxComboBoxProperties;
begin
  AProperties := cxGrid1DBTableView1Names.Properties as TcxComboBoxProperties;
  dxMemData1.DisableControls;
  try
    dxMemData1.Append;
    AProperties.Items.Add(AText);
    cxGrid1DBTableView1Names.DataBinding.Field.AsString := AText;
    dxMemData1.Post;
  finally
    dxMemData1.EnableControls;
  end;
end;

Direct TcxNewLookupDisplayTextEvent Type Reference

The TcxCustomTextEditProperties.OnNewLookupDisplayText event references the TcxNewLookupDisplayTextEvent procedural type.

See Also