0

我有一个用 C# 编写的 Winforms 应用程序。

我可以成功地将值从一个 DataGridView 拖放到同一表单上的另一个 DataGridView。

但是,我不确定如何确定 DragDrop 操作终止接收 DataGridView 中的哪个 Cell。

我尝试了以下代码 -

private void dataContactBusiness_DragDrop(object sender, DragEventArgs e)
{
    var cell = dataContactBusiness.HitTest(e.X, e.Y);

    //...other operations continue here    
}

但是我的命中测试总是超出范围,即返回-1 的行和列索引。

4

1 回答 1

0

我使用了以下代码并且它有效

Point dscreen = new Point(e.X, e.Y);
Point dclient = dataGridView1.PointToClient(dscreen );
DataGridView.HitTestInfo hitTest = dataGridView1.HitTest(dclient.X,dclient.Y);

根据 o_weisman 评论

于 2013-10-22T17:42:13.123 回答