ListForm.pas
资源名称:delphi.rar [点击查看]
上传用户:fh681027
上传日期:2022-07-23
资源大小:1959k
文件大小:1k
源码类别:
Delphi控件源码
开发平台:
Delphi
- unit ListForm;
- interface
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls;
- type
- TForm1 = class(TForm)
- ButtonAdd: TButton;
- ButtonList: TButton;
- ListBox1: TListBox;
- ButtonWrong: TButton;
- procedure ButtonAddClick(Sender: TObject);
- procedure ButtonListClick(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure ButtonWrongClick(Sender: TObject);
- procedure FormDestroy(Sender: TObject);
- private
- ListDate: TList;
- public
- { Public declarations }
- end;
- var
- Form1: TForm1;
- implementation
- {$R *.DFM}
- uses
- Dates;
- procedure TForm1.ButtonAddClick(Sender: TObject);
- begin
- ListDate.Add (TDate.Create (
- 1900 + Random (200), 1 + Random (12), 1 + Random (30)));
- end;
- procedure TForm1.ButtonListClick(Sender: TObject);
- var
- I: Integer;
- begin
- ListBox1.Clear;
- for I := 0 to ListDate.Count - 1 do
- Listbox1.Items.Add ((TObject(ListDate [I]) as TDate).Text);
- end;
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- Randomize;
- ListDate := TList.Create;
- end;
- procedure TForm1.ButtonWrongClick(Sender: TObject);
- begin
- // add a button to the list
- ListDate.Add (Sender);
- end;
- procedure TForm1.FormDestroy(Sender: TObject);
- var
- I: Integer;
- begin
- for I := 0 to ListDate.Count - 1 do
- TObject(ListDate [I]).Free;
- ListDate.Free;
- end;
- end.