本文介绍了拖放多个项从一个列表框移到另一个列表框.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

有谁能建议我一种使用C#在Windows窗体应用程序中实现将多个项目从一个列表框拖放到另一个列表中的方法.我可以为单个项目实现两个列表框之间的拖放,但是却被多个项目实现所打击...

感谢Advance

Hi All,

Can any one suggest me a way to implemt dragging and dropping multiple items from one listbox to another in windows forms application using C#. I am able to implement drag and drop between two listboxes for a single item but got struck with multiple items implementation...

Thanks in Advance

推荐答案

私有 void listViewSource_ItemDrag( 对象 发件人,ItemDragEventArgs e)
{
font style ="color:blue">如果 ( this .listViewSource.SelectedIndices.Coun t> 0)
{{
List< Person> selectedPersons = List< Person>();
foreach ( int 索引 输入 .listViewSource.SelectedIndices)
selectedPersons.Add( this .sourceList [index]);
}
font style ="color:blue">此 .listViewSource.DoDragDrop(selectedPersons,DragDropEffects.Copy || DragDropEffects.Move);
}
private void listViewSource_ItemDrag(object sender, ItemDragEventArgs e) 
        { 
            if (this.listViewSource.SelectedIndices.Count > 0) 
            { 
                List<Person> selectedPersons = new List<Person>(); 
                foreach (int index in this.listViewSource.SelectedIndices) 
                { 
                    selectedPersons.Add(this.sourceList[index]); 
                } 
                this.listViewSource.DoDragDrop(selectedPersons, DragDropEffects.Copy | DragDropEffects.Move); 
            } 
        } 


这篇关于拖放多个项从一个列表框移到另一个列表框.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 14:31