⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.~pas

📁 本光盘是《Delphi 7应用教程》一书的配套光盘
💻 ~PAS
字号:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    ListBox1: TListBox;
    Label1: TLabel;
    Label2: TLabel;
    procedure Edit1KeyPress(Sender: TObject; var Key: Char);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
var
  m:Integer;
begin
  if key=#13 then               //Enter键的ASCII值为13
    begin
      for m:=0 to ListBox1.Count-1 do//ListBox1.Count为列表框的总项数
        if Edit1.Text=ListBox1.Items[m] then
          begin
            Edit1.SelectAll;      //编辑框以高亮度显示
            break;                //终止整个循环
          end;
      if m=ListBox1.Count then   //说明编辑框文本不在列表框中
        ListBox1.Items.Add(Edit1.Text); //添加到列表框
    end;
end;

end.

⌨️ 快捷键说明

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