WinForm DataGridView & WPF DataGrid 的拖拽(Drag & Drop)[z]
2012-09-04 18:35
543 查看
http://www.cnblogs.com/lichence/archive/2012/02/06/2340351.html
Download Source - 117KB
如上述两图,左侧为WinForm的DataGridView,右侧为WPF的DataGrid(封装成了自定义控件DragDataGrid,通过WPF的ElementHost装载在WinForm中)。均可以通过左键拽取行进行拖拽排序。另外实现了从WinForm的DataGridView向WPF的DataGrid的拖拽,因此,两个DataGridView之间的拖拽和两个DataGrid的拖拽方法类似。以上控件均关闭了Sort功能,并将AllowDrop属性置为true.
WinForm DataGridView的行拖拽使用Drag & Drop系列方法通过e.Data.GetData()来传递拽取的行数据,TipPanel的移动显示在MouseMove中控制
WPF DataGrid的行拖拽使用一个老外的Blog上的方法,点击这里
DataGridView 与 DataGrid之间的拖拽由于在WPF的DataGrid的DragEnter方法里,使用如下代码会报COM异常
TipControl & Popup在WinForm中使用了一个TipControl的UserControl显示拖拽过程中的行信息
在WPF中使用Popup显示当前行信息
按住Ctrl键再拖拽行,则实现数据行赋值功能。
存在的问题:还存在一些BUG和不足,个人学习,仅供参考。
Download Source - 117KB
如上述两图,左侧为WinForm的DataGridView,右侧为WPF的DataGrid(封装成了自定义控件DragDataGrid,通过WPF的ElementHost装载在WinForm中)。均可以通过左键拽取行进行拖拽排序。另外实现了从WinForm的DataGridView向WPF的DataGrid的拖拽,因此,两个DataGridView之间的拖拽和两个DataGrid的拖拽方法类似。以上控件均关闭了Sort功能,并将AllowDrop属性置为true.
WinForm DataGridView的行拖拽使用Drag & Drop系列方法通过e.Data.GetData()来传递拽取的行数据,TipPanel的移动显示在MouseMove中控制
WPF DataGrid的行拖拽使用一个老外的Blog上的方法,点击这里
DataGridView 与 DataGrid之间的拖拽由于在WPF的DataGrid的DragEnter方法里,使用如下代码会报COM异常
1 DataGridViewRow curRow = (DataGridViewRow)e.Data.GetData(typeof(DataGridViewRow));所以封装了一个数据序列化类DataSerializer将当前DataGridView 拖拽行的DataBoundItem序列化为string类型,在WPF中使用如下代码获取string后再反序列化为实例对象。
string strRow = (string)e.Data.GetData(DataFormats.StringFormat); Animal aimAnimal = (Animal)DataSerializer.DeserializeObject(strRow);
TipControl & Popup在WinForm中使用了一个TipControl的UserControl显示拖拽过程中的行信息
在WPF中使用Popup显示当前行信息
按住Ctrl键再拖拽行,则实现数据行赋值功能。
存在的问题:还存在一些BUG和不足,个人学习,仅供参考。
相关文章推荐
- WinForm DataGridView & WPF DataGrid 的拖拽(Drag & Drop)
- 在WPF中通过DataTemple实现Drag&Drop控件
- Atitit。D&D drag&drop拖拽功能c#.net java swing的对比与实现总结
- HTML5 drag & drop 拖拽与拖放简介
- 给力的 Google HTML5 训练营(HTML5 Drag&Drop 拖拽、FileReader实例教程
- 拖拽上传详解(HTML5 Drag&Drop、FileReader API、formdata)
- WPF 的拖拽操作(DragDrop)
- HTML5 drag & drop 拖拽与拖放简介
- HTML5 drag & drop 拖拽与拖放简介
- atitit.D&D drag&drop拖拽文件到界面功能 html5 web 跟个java swing c#.net c++ 的总结
- [转]人人网首页拖拽上传详解(HTML5 Drag&Drop、FileReader API、formdata)
- GXT之旅:第八章:Portal&Drag-Drop——拖拽(Drag-Drop)基本介绍
- wpf的datagrid和winform的datagridview刷新
- atitit.D&D drag&drop拖拽文件到界面功能 html5 web 跟个java swing c#.net c++ 的总结
- delphi 控件 TEmbeddedWB 实现超级拖拽 (super Drag&Drop OR inline Drag&Drop)
- drag & drop 拖拽与拖放简介
- HTML5 drag & drop 拖拽与拖放简介
- HTML5原生拖拽/拖放(drag & drop)详解
- WPF 实现拖放的简单实例(Drag & Drop)
- HTML5 drag & drop 拖拽与拖放简介