delphi.listbox的问题?

来源:百度知道 编辑:UC知道 时间:2024/05/19 10:33:22
高手给点提示,我实在是不知道该怎么做?
窗体上放至两个listbox,其中listbox1中存在一些items,我想先选定listbox1中的项目,可以多选,再点击向右按钮>>,把选中的项目添加到listbox2中,同理,选中listbox2上的项目,可以多选,点击向左按钮<<,添加到listbox1中,这个怎么做啊?

先设置ListBox1的MultiSelect为true

procedure TForm1.Add1Click(Sender: TObject);
var
i:Integer;
begin
for i :=0 to ListBox1.Count-1 do
begin
if ListBox1.Selected[i] then
ListBox2.Items.Add(ListBox1.Items.Strings[i]);
end;
ListBox1.DeleteSelected;//增加后删除所选的记录
end;