• Winform ListView 元素拖动


    //ListView 属性
            /* AllowDrop : True */
    
            ListView objLVDrag;
            private void listView_DragDrop(object sender, DragEventArgs e)
            {
                //获取拖动的数据项创建数组
                ListView.SelectedListViewItemCollection items = e.Data.GetData("wjshan0808") as ListView.SelectedListViewItemCollection;
                foreach (ListViewItem item in items)
                {
                    //向目的空间中添加
                    ((ListView)(sender)).Items.Add(item.Text);
                    //从源控件中移除
                    objLVDrag.Items.Remove(objLVDrag.SelectedItems[0]);
                }
            }
            private void listView_ItemDrag(object sender, ItemDragEventArgs e)
            {
                // System.Windows.Forms.DataFormats 
                objLVDrag = sender as ListView;
                //自定义DataFormats的拖动数据格式
                objLVDrag.DoDragDrop(new DataObject("wjshan0808", objLVDrag.SelectedItems), DragDropEffects.Move);
            }
            private void listView_DragEnter(object sender, DragEventArgs e)
            {
                //检测自定义的DataFormat ListView数组
                if (e.Data.GetDataPresent("wjshan0808"))
                    e.Effect = DragDropEffects.Move;//移动数据
                else
                    e.Effect = DragDropEffects.None;
            }
  • 相关阅读:
    JDBC操作MySQL
    MySQL-SQL语句
    MySQL-环境安装、配置、卸载、系统介绍
    JavaSE-单元测试、反射、注解
    JavaSE-Stream、方法引用
    JavaSE-函数式编程接口
    JavaSE-网络编程
    Document
    Document
    Document
  • 原文地址:https://www.cnblogs.com/wjshan0808/p/4260359.html
Copyright © 2020-2023  润新知