腾讯微群加入QQ群

 找回密码
 加入我们

!connect_header_login!

!connect_header_login_tip!

搜索
查看: 230|回复: 0

DevExpress 从一个XtraGridControl 拖拽行到另外一个

[复制链接]
发表于 2016-8-11 18:15:00 | 显示全部楼层 |阅读模式
using DevExpress.XtraGrid;

using DevExpress.XtraGrid.Views.Base;

using DevExpress.XtraGrid.Views.Grid;

using DevExpress.XtraGrid.Views.Grid.ViewInfo;



GridHitInfo downHitInfo = null;



private void view_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) {

    GridView view = sender as GridView;

    downHitInfo = null;

    GridHitInfo hitInfo = view.CalcHitInfo(new Point(e.X, e.Y));

    if(Control.ModifierKeys != Keys.None) return;

    if(e.Button == MouseButtons.Left && hitInfo.RowHandle >= 0)

        downHitInfo = hitInfo;

}



private void view_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) {

    GridView view = sender as GridView;

    if(e.Button == MouseButtons.Left && downHitInfo != null) {

        Size dragSize = SystemInformation.DragSize;

        Rectangle dragRect = new Rectangle(new Point(downHitInfo.HitPoint.X - dragSize.Width / 2,

            downHitInfo.HitPoint.Y - dragSize.Height / 2), dragSize);



        if(!dragRect.Contains(new Point(e.X, e.Y))) {

            DataRow row = view.GetDataRow(downHitInfo.RowHandle);

            view.GridControl.DoDragDrop(row, DragDropEffects.Move);

            downHitInfo = null;

            DevExpress.Utils.DXMouseEventArgs.GetMouseArgs(e).Handled = true;

        }

    }

}

0
0

转自:http://blog.csdn.net/jjhua/article/details/50649699
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 加入我们

本版积分规则

QQ|手机版|Archiver|小黑屋|一起疯|苦咖啡 ( 新ICP备12000197号  

GMT+8, 2018-1-19 05:55 , Processed in 0.060940 second(s), 12 queries , Memcache On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表