主题:控件使用经验一【arraylist与web 控件的绑定】
摘自:----www.evget.com---慧都控件网
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));
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));