问题描述
我现在有两个ListBox控件我想把我选的值拖到另外一个ListBox里面我自己写了一段代码不知那里有问题?望高手帮小弟看看privatevoidlistBox1_MouseDown(objectsender,MouseEventArgse)//文本源{for(inti=0;i<listBox1.Items.Count;i++)if(listBox1.GetSelected(i))listBox1.DoDragDrop(listBox1.Items[i],DragDropEffects.Copy|DragDropEffects.Move);}privatevoidlistBox2_DragEnter(objectsender,DragEventArgse)//要拖入的listbox{if(e.Data.GetDataPresent(DataFormats.Text))e.Effect=DragDropEffects.Copy;elsee.Effect=DragDropEffects.None;}privatevoidlistBox2_DragDrop(objectsender,DragEventArgse){listBox2.Items.Add(e.Data.GetData(DataFormats.Text).ToString());for(inti=0;i<listBox1.Items.Count;i++)if(listBox1.GetSelected(i))this.listBox1.Items.Remove(i);MessageBox.Show("Runningishere");}
时间: 2024-10-03 11:57:40