把一个listbox多选的内容导入到另一个listbox中的问题(30分)

  • 主题发起人 主题发起人 liuyang
  • 开始时间 开始时间
L

liuyang

Unregistered / Unconfirmed
GUEST, unregistred user!
条目是连续的导入没问题,要是选择的不是连续的就不对了(选择的是前几个(选择三个就是前三条)),谁能帮我改一改呢?代码如下<br>procedure Tf_main.sB_swyy2Click(Sender: TObject);<br>var<br> Iitemno,Ino,i: Integer;<br> ifsame:boolean;<br>begin<br> &nbsp;Iitemno:=0;<br> &nbsp;with sLB_swyyqb do<br> &nbsp;for Ino:=0 to Items.Count-1 do<br> &nbsp;begin<br> &nbsp; &nbsp;if Selected[Ino] then<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp;Iitemno:=Ino;<br> &nbsp; &nbsp; &nbsp;Break;<br> &nbsp; &nbsp;end;<br> &nbsp;end;<br><br> &nbsp;ifsame:=false;<br> &nbsp;with sLB_swyyqb do<br> &nbsp;begin<br> &nbsp; &nbsp;for Ino:=Iitemno to Iitemno+(sLB_swyyqb.SelCount-1) do<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp;for i:=0 to sLB_swyyxz.Items.Count-1 do<br> &nbsp; &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp;if Items[Ino]= sLB_swyyxz.Items then<br> &nbsp; &nbsp; &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ifsame:=true;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;<br> &nbsp; &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp; &nbsp; &nbsp;ifsame:=false;<br> &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp; &nbsp;if ifsame=false then sLB_swyyxz.Items.Add(Items[Ino]);<br> &nbsp; &nbsp;end;<br> &nbsp;end;<br>end;
 
这样就好,不需要你那么复杂<br>var<br> &nbsp;i:Integer;<br>begin<br> &nbsp;for i:=0 to sLB_swyyqb.Items.Count-1 do<br> &nbsp;begin<br> &nbsp; &nbsp;if sLB_swyyqb.Selected then<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp;sLB_swyyxz.Items.Add(sLB_swyyqb.Items.Strings);<br> &nbsp; &nbsp;end;<br> &nbsp;end;<br>end;
 
ListBox1.Items.CommaText
 
这样就好,不需要你那么复杂<br>var<br> &nbsp;i:Integer;<br>begin<br> &nbsp;for i:=0 to sLB_swyyqb.Items.Count-1 do<br> &nbsp;begin<br> &nbsp; &nbsp;if sLB_swyyqb.Selected then<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp;sLB_swyyxz.Items.Add(sLB_swyyqb.Items.Strings);<br> &nbsp; &nbsp;end;<br> &nbsp;end;<br>end;
 
多人接受答案了。
 

Similar threads

I
回复
0
查看
895
import
I
S
回复
0
查看
896
SUNSTONE的Delphi笔记
S
S
回复
0
查看
873
SUNSTONE的Delphi笔记
S
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
后退
顶部