drag and drop cell from datagridview to another

后端 未结 3 511
闹比i
闹比i 2020-12-15 11:08

I have 2 datagridviews and i want to copy cells from the datagridview1 to datagridview2 (a cell at a time).I´m able to select the cell I want and drag it to the datagridview

3条回答
  •  余生分开走
    2020-12-15 11:38

    The error is in this line:

    Point cursorLocation = this.PointToClient(new Point(e.X,e.Y));
    

    Because this. does not refer to the DataGridView, but rather to the Form.

    It should be instead:

    Point cursorLocation = dataGridView2.PointToClient(new Point(e.X,e.Y));
    

提交回复
热议问题