【发布时间】:2015-12-04 02:26:11
【问题描述】:
我有一个类对象
TContact = class(TObject)
private
FChild: TContact;
FLastname: string;
FFirstname: string;
FAge: Integer;
procedure SetFirstname(const Value: string);
procedure SetLastname(const Value: string);
public
constructor Create(AFirstname: string = ''; ALastname: string = ''; AChild :
TContact = nil; AAge : Integer = 10);
property Child: TContact read FChild write FChild;
property Firstname: string read FFirstname write SetFirstname;
property Lastname: string read FLastname write SetLastname;
property Age: Integer read FAge write FAge;
end;
我想在 TcxGridTableView 中显示一些对象。这是我在 TcxGridTableView 上显示一些对象的代码
var
lFather: TContact;
list: IList<TObject>;
lJon: TContact;
lMother: TContact;
begin
list := TObservableCollection<TObject>.Create();
lJon := TContact.Create('Jericho', 'Doe', TContact.Create('No Child'),8);
lFather := TContact.Create('John', 'Doe', lJon, 48);
lMother := TContact.Create('Nancy', 'More', lJon, 45 );
list.Add(lJon);
list.Add(lFather);
list.Add(lMother);
prescontactpresenter.View.ItemsSource := list.AsList;
end;
一切运行良好。我可以修改 FirstName 和 Lastname 的值。但是,当我直接在年龄列上修改值 Age 属性时,出现以下错误:
但是当我将 Age 属性绑定到 Tedit 时,我可以修改它的值。有谁知道这是怎么回事?
【问题讨论】: