FMX.Edit.TCustomEditModel

From RAD Studio API Documentation
Jump to: navigation, search

FMX.Controls.Model.TDataModelFMX.Presentation.Messages.TMessageSenderSystem.Classes.TPersistentSystem.TObjectTCustomEditModel

Delphi

TCustomEditModel = class(TDataModel)

C++

class PASCALIMPLEMENTATION TCustomEditModel : public Fmx::Controls::Model::TDataModel

Properties

Type Visibility Source Unit Parent
class public
FMX.Edit.pas
FMX.Edit.hpp
FMX.Edit FMX.Edit

Description

Data models for presented controls.

FMX.Edit.TCustomEditModel inherits from FMX.Controls.Model.TDataModel. All content below this line refers to FMX.Controls.Model.TDataModel.

Data models for presented controls.

TDataModel is the base class of data models for presented controls. Descendant classes define properties that store data values used by properties of corresponding presented controls.

TDataModel extends TMessageSender, which provides the sending messages functionality. A Data model can define a Receiver (or presentation) and send messages to this Receiver, when a Data model's data is changed, to update the values shown in the associated presented control. When a Data model reads or writes Data values the Data model sends MM_GETDATA and MM_DATA_CHANGED messages to a presentation.

TDataModel defines the DataSource property containing a collection of key-value pairs. Keys are strings and values are instances of TValue. Since the TValue type can keep and handle any arbitrary type data; therefore, the DataSource collection can keep any required data. This means that to keep any type data TDataModel does not need to create a new separate class. For example, it can keep an array of strings, which can be used as a collection of prompt words in an editor. Like this:

type
  TStringArray = TArray<string>;
var
  ArrayList1, ArrayList2: TStringArray;
...
  { Setting/Getting value of array type }
  ArrayList1 := ['Apple', 'ARC', 'Auto', 'Allday', 'Alltime'];
  Edit1.Model.Data['array_value'] := TValue.From<TStringArray>(ArrayList1);
  ...
  if Edit1.Model.Data['array_value'].IsType<TStringArray> then
    ArrayList2 := Edit1.Model.Data['array_value'].AsType<TStringArray>;

When you create a data model, you must pass a presentation control to the constructor. The specified presentation control owns the model.

See Also