Delphi 样例-属性编辑器

运行效果如下

窗体布局

object Form1: TForm1
  Left = 0
  Top = 0
  Caption = #31034#20363'-'#23646#24615#32534#36753#22120
  ClientHeight = 243
  ClientWidth = 527
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
  object cxRTTIInspector1: TcxRTTIInspector
    Left = 8
    Top = 8
    Width = 297
    Height = 227
    InspectedObject = Owner
    OptionsView.RowHeaderWidth = 120
    OptionsView.ShowReadOnlyProperties = True
    TabOrder = 0
    Version = 1
  end
end

窗体代码

unit Unit1;
 
interface
 
uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls,
  Vcl.StdCtrls,
  Vcl.Forms, Vcl.Dialogs, cxClasses, cxPropertiesStore,
  cxGraphics, cxControls, cxLookAndFeels, cxLookAndFeelPainters, cxStyles,
  cxEdit, dxSkinsCore, dxSkinCoffee, cxInplaceContainer, cxVGrid, cxOI,
  Vcl.ExtDlgs;
 
type
  TMyObj = class(TPersistent)
  private
    FLength: Integer;
    FWidth: Integer;
    FColor: TColor;
    FLines: TStrings;
    procedure SetLines(const Value: TStrings);
  published
    property Length  : Integer  read FLength  write FLength;
    property Width   : Integer  read FWidth   write FWidth;
    property Color   : TColor   read FColor   write FColor;
    property Lines   : TStrings read FLines   write SetLines;
  public
    constructor Create();
  end;
  TForm1 = class(TForm)
    cxRTTIInspector1: TcxRTTIInspector;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    obj1 : TMyObj;
  end;
 
var
  Form1: TForm1;
 
implementation
 
{$R *.dfm}
 
procedure TForm1.FormCreate(Sender: TObject);
begin
  obj1 := TMyObj.Create();
  obj1.Length := 10;
  cxRTTIInspector1.InspectedObject := obj1;
end;
 
{ TMyObj }
 
constructor TMyObj.Create;
begin
  inherited;
  FLines := TStringList.Create;
end;
 
procedure TMyObj.SetLines(const Value: TStrings);
begin
  FLines.Assign(Value);
end;
 
end.

未解决的问题

属性的提示如何显示为中文?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ok060

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值