How can I drag and drop an item in a listview if I don"t know which column the item will be in?
The SilkTest help files have the following to say about identifying an object in a listview:-
Items in a listview can be identified by either of the following: The simple name of the item in the first column A string containing a semicolon that specifies the content of one or more columns The following examples show how you can identify items within a listview: This specification... Identifies this item... "x" An item "x" in the first column "x;y;z" An item "x" in the first column, "y" in the second column, and "z" in the third column "*;*;z" An item "z" in the third column "x;y" An item "x" in the first column, and an item "y" in the second column "x;*;z " An item "x" in the first column, and "z" in the third column
We can take advantage of this to specify an item anywhere in any column without knowing its exact positioning. The following code snippet counts the number of columns on the desktop and then appends this as a suffix to the item to be dragged. This forces SilkTest to read every column until it finds the specified object to drag and then forces it to read every column again until it finds the drag destination.
//Window declarations [-] window DialogBox ProgramManager [ ] tag "Program Manager" [-] ListView ListView1 [ ] tag "$1" //Drag and drop code [-] testcase DragTest() appstate none [ ] integer iCols=0 [ ] integer iItems=0 [ ] string sSuffix="" [ ] [ ] ProgramManager.SetActive () [ ] window wDeskTop = ProgramManager.ListView1 [ ] iCols = wDeskTop.GetColumnCount() [ ] sSuffix = Replicate(";*",iCols - 1) [ ] ProgramManager.ListView1.BeginDrag (1,""+sSuffix) [ ] ProgramManager.ListView1.EndDrag (""+sSuffix)
= the name of a object on your desktop you wish to drag.
= the name of a object on your desktop you wish to drag into.