listbox多选问题(20分)

  • 主题发起人 主题发起人 xito_76
  • 开始时间 开始时间
X

xito_76

Unregistered / Unconfirmed
GUEST, unregistred user!
listbox1设为多选,将所选择项放入listbox2中.(自己只会用itemIndex得到最后选项的1项条目,不会用多选)
 
procedure TForm1.btn1Click(Sender: TObject);<br>var<br>&nbsp; i:integer;<br>begin<br>&nbsp; for I := 0 to lst1.Count - 1 do &nbsp; &nbsp;// Iterate<br>&nbsp; begin<br>&nbsp; &nbsp; if lst1.Selected then<br>&nbsp; &nbsp; &nbsp; lst2.Items.AddObject(lst1.Items.Strings,lst1.Items.Objects)<br>&nbsp; end; &nbsp; &nbsp;// for<br><br>end;<br><br>end.
 
procedure Tlotfrm.Button1Click(Sender: TObject);<br>var i:integer;<br>begin<br>&nbsp; while listbox1.SelCount&gt;0 do<br>&nbsp; begin<br>&nbsp; &nbsp; i:=listbox1.ItemIndex;<br>&nbsp; &nbsp; if ListBox1.Selected then<br>&nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp;ListBox2.Items.Insert(0,ListBox1.Items);<br>&nbsp; &nbsp; &nbsp; &nbsp;ListBox1.Items.Delete(i);<br>&nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; end;<br>end;
 
接受答案了.(谢lhcming)
 
后退
顶部