Invalid coordinates from dataGridView HitTest

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?UGFycm90?=

    Invalid coordinates from dataGridView HitTest

    I am trying to implement a drag and drop operation from a listbox to a data
    gridview control but I keep getting -1 for my row index when the dragdrop
    function is executed. Below is my coding.

    DataGridView.Hi tTestInfo info = dataGridView2.H itTest(e.X, e.Y);
    int row = info.RowIndex;

    The coordinates returned to the dragdrop function seem to be coordinates
    relative to the window rather than to the datagridview control. In any case,
    I get -1 for of the indices returned in the info group. Does anyone know how
    to get the correct row in a dragdrop into a datagridview.
    Dave
  • Stefano Tonello

    #2
    Re: Invalid coordinates from dataGridView HitTest

    Parrot ha scritto:
    I am trying to implement a drag and drop operation from a listbox to a data
    gridview control but I keep getting -1 for my row index when the dragdrop
    function is executed. Below is my coding.
    >
    DataGridView.Hi tTestInfo info = dataGridView2.H itTest(e.X, e.Y);
    int row = info.RowIndex;
    >
    The coordinates returned to the dragdrop function seem to be coordinates
    relative to the window rather than to the datagridview control. In any case,
    I get -1 for of the indices returned in the info group. Does anyone know how
    to get the correct row in a dragdrop into a datagridview.
    Dave
    Hi Parrot,
    you have to use
    Control.PointTo Client(pt)

    Bests,
    Stefano

    Comment

    • =?Utf-8?B?UGFycm90?=

      #3
      Re: Invalid coordinates from dataGridView HitTest

      Stefano:
      Thanks for your reply. I inserted the following command before the HitTest
      as shown below and the row index was correct.

      Point p = dataGridView2.P ointToClient(ne w Point(e.X, e.Y);
      DataGridView.Hi tTestInfo info = dataGridView2.H itTest(p.X, p.Y);
      int row = info.RowIndex;

      Thanks for your help.


      "Stefano Tonello" wrote:
      Parrot ha scritto:
      I am trying to implement a drag and drop operation from a listbox to a data
      gridview control but I keep getting -1 for my row index when the dragdrop
      function is executed. Below is my coding.

      DataGridView.Hi tTestInfo info = dataGridView2.H itTest(e.X, e.Y);
      int row = info.RowIndex;

      The coordinates returned to the dragdrop function seem to be coordinates
      relative to the window rather than to the datagridview control. In any case,
      I get -1 for of the indices returned in the info group. Does anyone know how
      to get the correct row in a dragdrop into a datagridview.
      Dave
      >
      Hi Parrot,
      you have to use
      Control.PointTo Client(pt)
      >
      Bests,
      Stefano
      >

      Comment

      Working...