Imports System.Windows.Forms

Public Class Dialog1

  Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
    Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
    Me.Close()
  End Sub

  Private Sub Button1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseDown

    Dim myComponent As String = "COMPONENT"
    ' Creates a new data object.
    Dim myDataObject As New DataObject()
    ' Adds the component to the DataObject.
    myDataObject.SetData(myComponent)
    ' Prints whether data of the specified type is in the DataObject.
    Dim myType As Type = myComponent.GetType()
    If myDataObject.GetDataPresent(myType) Then
      TextBox1.Text = "***" & myDataObject.GetData(DataFormats.Text, True)
    Else
      TextBox1.Text = "no data"
    End If

    Debug.Print("Starting drag")
    Debug.Print(Button1.DoDragDrop("Drag data", DragDropEffects.Copy).ToString)
    Debug.Print("Ending drag")
    Me.Close()
  End Sub

  Private Sub Dialog1_GiveFeedback(ByVal sender As Object, ByVal e As System.Windows.Forms.GiveFeedbackEventArgs) Handles Me.GiveFeedback
    Debug.Print(sender.ToString & " " & e.ToString)
  End Sub
End Class
