我们先来看下运行效果图
Form1.cs代码:
使用系统; 使用System.Collections.Generic; 使用System.ComponentModel; 使用System.Data; 使用System.Drawing; 使用来; 使用text; 使用System.Threading.Tasks; 使用System.Windows.Forms; 使用System.Collections; 名称空间MoveItem { 公共部分中类Form1:形式 { 公共Form1 () { InitializeComponent (); } ArrayList列表=new ArrayList (); 私人空间listBox1_SelectedIndexChanged(对象发送方,EventArgs e) { } 私人空间Form1_Load(对象发送方,EventArgs e) { for (int i=1;我& lt;=10;我+ +) { list.Add(我); 字符串s=i.ToString (); listBox1.Items.Add(年代); } } 私人空间listBox2_SelectedIndexChanged(对象发送方,EventArgs e) { } 私人空间button1_Click(对象发送方,EventArgs e) {//单选,无法实现多?/字符串str=this.listBox1.Text.Trim () .ToString ();//如果(listBox1.Items.Contains (str))//{//listBox1.Items.Remove (str);//listBox2.Items.Add (str);//} for (int i=0; i大家可以测试运行下,有其他问题可以在下方的留言区讨论,感谢大家对的支持。
c#列表框中的物品拖拽代码分享