Frequently Asked Component Specific Questions

Options

Display all FAQ items

Search FAQ items:


Displaying items 1 to 1 of 1, page 1 of 1

<< previous next >>

TMS FMX UI Pack
TTMSFMXListEditor: How to have a lookup function

Example:

procedure TForm1.DoApplyStyleLookup(Sender: TObject);
var
  b: TFMXObject;
  c: TFMXObject;
begin
  if Sender is TFMXObject then
  begin
    c := Sender as TFMXObject;
    if Sender is TTMSFMXEdit then
    begin
      if c.ChildrenCount > 0 then
        c := c.Children[0];
      b := c.FindStyleResource(''background'');
      if Assigned(b) and (b is TControl) then
        (b as TControl).Visible := False;
    end;
  end;
end;

procedure TForm1.TMSFMXListEditor1EditorCreate(Sender: TObject;
  var AClass: TTMSFMXCustomListEditorControlClass);
begin
  AClass := TTMSFMXEdit;
end;

procedure TForm1.TMSFMXListEditor1EditorUpdate(Sender: TObject;
  AItemIndex: Integer; var AText: string);
var
  ed: TStyledControl;
begin
  ed := TMSFMXListEditor1.Editor;
  if Assigned(ed) then
  begin
    (ed as TTMSFMXEdit).Text := AText;
    (ed as TTMSFMXEdit).Lookup.Enabled := True;
    (ed as TTMSFMXEdit).Lookup.DisplayList.Add(''Item 1'');
    (ed as TTMSFMXEdit).Lookup.DisplayList.Add(''Item 2'');
    (ed as TTMSFMXEdit).Lookup.DisplayList.Add(''Item 3'');
    (ed as TTMSFMXEdit).OnApplyStyleLookup := DoApplyStyleLookup;
  end;
end;

procedure TForm1.TMSFMXListEditor1ItemUpdate(Sender: TObject;
  AItemIndex: Integer; var AText: string);
var
  ed: TStyledControl;
begin
  ed := TMSFMXListEditor1.Editor;
  if Assigned(ed) then
    AText := (ed as TTMSFMXEdit).Text;
end;

Result when typing in the editor:

KB87