unit1.~pas

来自「这有很多Delphi应用的例子」· ~PAS 代码 · 共 64 行

~PAS
64
字号
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    ListBox1: TListBox;
    Label1: TLabel;
    Edit1: TEdit;
    Label2: TLabel;
    Label3: TLabel;
    Memo1: TMemo;
    ComboBox1: TComboBox;
    Label4: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  Memo1.Lines.Add(Edit1.Text);       //添加国名到Tmemo中
  If ListBox1.ItemIndex>=0           //用户在ListBox中已作选择
     Then Memo1.Lines.Add(ListBox1.Items[ListBox1.ItemIndex]); //添加大洲名到Memo中
  Memo1.Lines.Add(ComboBox1.Text);
end;





procedure TForm1.FormCreate(Sender: TObject);
begin
  ListBox1.Items.Add('亚洲');
  ListBox1.Items.Add('非洲');
  ListBox1.Items.Add('欧洲');
  ListBox1.Items.Add('北美洲');
  ListBox1.Items.Add('南美洲');
  ListBox1.Items.Add('大洋洲');
  ListBox1.Items.Add('南极洲');
  ComboBox1.SelText
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
  ListBox1.Clear;
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?