How To Drag and Drop from a Grid to a Text Box (137435)



The information in this article applies to:

  • Microsoft Visual FoxPro for Windows 3.0
  • Microsoft Visual FoxPro for Windows 5.0
  • Microsoft Visual FoxPro for Windows 6.0

This article was previously published under Q137435

SUMMARY

This article shows by example how to drag text from a cell in a grid to a text box on a form.

MORE INFORMATION

Step-by-Step Example

  1. Create a form called Dragndrop.
  2. Add the Customer table located in \Samples\Data to the environment.
  3. Place a grid on the form.
  4. Change the ColumnCount to 3.
  5. In the Properties window, select the Text1 object located in the column of the grid. Place the following code in the MouseDown event of each [form1|Grid1|Column] Text1 object.
          This.Drag(1)
    							
  6. Add a text box to the form. Place the following line of code in the DragDrop event of the text box:
          This.Value = oSource.Value
    							
    NOTE: oSource is a parameter defined in a DragDrop event of an object. It is use in a DragDrop event as a reference to the control being . dragged You can refer to properties and methods of the control being dragged by using this oSource parameter.
  7. Run the form. Click any cell in the grid to select the field, and hold the mouse button down. Drag the mouse pointer to the text field, and release the mouse button to copy the contents of the grid cell into the text box.

Modification Type:MinorLast Reviewed:6/30/2004
Keywords:kbcode kbDesigner kbhowto KB137435