在TcxTimeEdit中显示自定义文本

2020-09-11

覆盖PrepareDisplayValue方法即可完成此任务


unit Unit4;


interface


uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, cxGraphics, cxControls, cxLookAndFeels, cxLookAndFeelPainters,

  cxContainer, cxEdit, cxTextEdit, cxMaskEdit, cxSpinEdit, cxTimeEdit, StdCtrls;


type

  TMycxTimeEdit = class(TcxTimeEdit)

  protected

    procedure PrepareDisplayValue(const AEditValue: TcxEditValue; var DisplayValue: TcxEditValue; AEditFocused: Boolean); override;

  end;


  TcxTimeEdit = class(TMycxTimeEdit);


  TForm4 = class(TForm)

    cxTimeEdit1: TcxTimeEdit;

    Edit1: TEdit;

  private

    { Private declarations }

  public

    { Public declarations }

  end;


var

  Form4: TForm4;


implementation


{$R *.dfm}


{ TMycxTimeEdit }


procedure TMycxTimeEdit.PrepareDisplayValue(const AEditValue: TcxEditValue;

  var DisplayValue: TcxEditValue; AEditFocused: Boolean);

begin

  inherited;

  if not AEditFocused then

    DisplayValue := DisplayValue + ' CET';

end;


end.



阅读197