cancel
Showing results for 
Search instead for 
Did you mean: 

drag and drop

svb
New Contributor

drag and drop

Trying to drag and drop cell in a IGridView to a cell in another grid using testleft C#. Similar requirement to this vbscript solution,

 

(https://community.smartbear.com/t5/TestComplete-Functional-Web/Drag-and-Drop-without-using-cordinate...)

 

I could probably work it out from above or hack together a cursor solution, but would prefer to do it properly. 

 

Does anyone have a way to do this in C# ? thanks

 

1 REPLY 1
svb
New Contributor

Re: drag and drop

the Drag() api doesn't suit controls outside the scope of the control that the drag is assigned to. Nor do I believe it acts as expected.

 

The drag() documentation says the arguments are,
The X coordinate of the start position
The Y coordinate of the start position
The X coordinate of the end position.
The Y coordinate of the end position.

It doesn't say that that the end is relative to the start. So if my start is x:1000 y :50 and my end is x:500 y:50 the arguments that would make the Drag() work would have to be IControl.Drag(1000,50,-500,0) and not Drag(1000,50,500,50).

 

I have a modal screen that contains 2 grids. I have to drag a row in one grid to a row in another grid. I'm able to filter both grid's results so that the rows I want have the same y co-ordinate, thereby making destination y=0 as outlined above. The row width is static so I can make the destination x = -500.The quickest solution i came up with (which is hideous), 

1. Write a native method to get x,y of Cursor position [user32.dll, GetCursorPos(out point)]

2. Click a cell in 1st grid (row that I want). Don't need to get destination grid x:y because I'm using relative values as explained. Use native method to get source x:y.

3. Call Drag() on modal form, not either of the grids. This is because the x:y may be out of bounds on grids. I also call form.Position(0,0,form.Width,form.Height) before step 2 so that poistion is consitent.

4. Call form.Drag(sourceX, sourceY, -500, 0)

 

This works, but not ideal.

New Here?
Join us and watch the welcome video:
Update to TestLeft 2.3
Labels