从blog.org的我的原博客中迁入
发表时间:2007-10-2 14:06:05
procedure TfrmPayment.LoadPayments;
var
i, j: integer;
aPayment: TPayment;
begin
FBalance := 150;
FBondBalance := 250;
for i := 0 to 4 do
begin
for j := 0 to 2 do
begin
aPayment := TPayment.Create;
aPayment.Staff := 'Dick Walker';
aPayment.Tender := 'CASH';
aPayment.Customer := 'Mike Smith';
aPayment.IsBond := false;
aPayment.NewPayment := false;
FPaymentList.Add(aPayment);
end;
end;
end;
// ArrayList loaded with data before being bound.
最关键的是arraylist是静态的,它的元素类型是system.object,绑定时要转化为对象数组类型
dgPayments.DataSource=(TPayment[])arrayList.ToArray(typeof(TPayment));