📄 unit1.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
mm:Integer;
begin
if key=#13 then //Enter键的ASCII值为13
begin
mm:=0;
while (mm<ListBox1.Count) do //ListBox1.Count为列表项的总数
begin
if Edit1.Text=ListBox1.Items[mm] then
begin
Edit1.SelectAll; //编辑框以高亮度显示
ListBox1.ItemIndex :=mm; //选中该列表项
break; //终止整个循环
end;
mm:=mm+1;
end;
if mm=ListBox1.Count then //说明编辑框文本不在列表框中
begin
ListBox1.Items.Add(Edit1.Text); //添加到列表框
Edit1.Text:='';
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -