📄 unit1.~pas
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
ListBox1: TListBox;
ListBox2: TListBox;
ButtonRS: TButton;
ButtonRSA: TButton;
ButtonLS: TButton;
ButtonLSA: TButton;
Label1: TLabel;
Label2: TLabel;
procedure ButtonRSClick(Sender: TObject);
procedure ButtonLSClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.ButtonRSClick(Sender: TObject);
Var
i:integer;
begin
For i:=Listbox1.Count-1 downto 0 do //遍历ListBox1的所有列表项,i代表列表项的序号
begin
if listBox1.Selected[i] then //如果i项被选中
begin
listbox2.Items.Add(listBox1.Items.Strings[i]);//把该项添加到ListBox2中
Listbox1.Items.Delete(i); //从该列表框中删除该项
end;
end;
ButtonLS.Enabled :=True; //左移按钮可用
ButtonLSA.Enabled :=True;//全部左移按钮可用
if ListBox1.Count =0 then //如果ListBox1中已经没有列表项
begin
ButtonRS.Enabled :=False;//右移按钮不可以用
ButtonRSA.Enabled :=False; //全部右移按钮不可用
end;
end;
procedure TForm1.ButtonLSClick(Sender: TObject);
Var
i:integer;
begin
For i:=Listbox2.Count-1 downto 0 do //遍历ListBox2的所有列表项,i代表列表项的序号
begin
if listBox2.Selected[i] then //如果i项被选中
begin
listbox1.Items.Add(listBox2.Items.Strings[i]);//把该项添加到ListBox1中
Listbox2.Items.Delete(i); //从该列表框中删除该项
end;
end;
ButtonRS.Enabled :=True; //右移按钮可用
ButtonRSA.Enabled :=True;//全部右移按钮可用
if ListBox2.Count =0 then //如果ListBox2中已经没有列表项
begin
ButtonLS.Enabled :=False;//左移按钮不可以用
ButtonLSA.Enabled :=False; //全部左移按钮不可用
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -