我有两个列表框,想实现这样的功能,如果选中几项就通过一个按钮把它移动到另一个列表框中,还有一个按钮能实现全部移动的功能。另外,再把这些选中的项插入到库里。谢谢!一解决,马上给分!
解决方案 »
- delphi如果访问外网的MS SQL SERVER 数据库。
- 求海康DS-6001最新SDK的Delphi Demo
- 多线程打开excel,中出现的问题!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- 2个有关在intraweb中编写javascript代码的问题,很急!在线等。
- 文件加密解密问题,急用在线等待。
- DBGrid列与列之间进行比较的问题在经等(数据库为sql server,表为动态生成的),急急在线等
- 请问哪儿有SkinEngine可下载呀
- 简单问题:哪些类申明后不用创建?
- 为什么我的专家分减了100多分呢?大家对新改版的CSDN对自己有多大的影响,出来说一下!!
- Delphi 的DBGrid错误捕捉
- delphi中的网络通讯组件Fastnet中的好还是Indy中的好
- 如果通过在程序中处理 运行批处理函数?
再用Delete从旧列表删除;
如果是多项的话就用循环.
procedure TForm1.Button1Click(Sender: TObject);
var
I: Integer;
begin
for I := 0 to ListBox1.Items.Count - 1 do
begin
if ListBox1.Selected[I] then
ListBox2.Items.Add(ListBox1.Items[I]);
end;
ListBox1.DeleteSelected;
end;// 移动所有项
procedure TForm1.Button2Click(Sender: TObject);
begin
ListBox2.Items.Text := ListBox2.Items.Text + ListBox1.Items.Text;
ListBox1.Items.Clear;
end;
var icount:integer;
begin
icount := lb1.ItemIndex;
if icount>=0 then
begin
lb2.Items.Append(lb1.Items.Strings[icount]);
lb1.Items.Delete(icount);
end;
if lb1.Items.Count>0 then
lb1.ItemIndex := icount;
if listbox4.Count>0 then btnprior.Enabled := false
else btnprior.Enabled := true;
end;
我怎么样实现按住Shift键进行连选呢?
楼上的各位朋友:我怎样实现移动的同时,再把这些项再写到对应的数据库中呢?
var
I: Integer;
begin
for I := 0 to ListBox1.Items.Count - 1 do
begin
if ListBox1.Selected[I] then
ListBox2.Items.Add(ListBox1.Items[I]);
end;
With Query1 do
beign
Sql.Clear;
Sql.Add(format('insert into tablename (aa) values (''%s'')',[ListBox1.Items[i]]));
end;
ListBox1.DeleteSelected;
end;
运行时出现List index out of bounds(17)这样的错误。