Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Does somebody know why I cant drag and drop a datarowview

 

here is the code that Ihave, it shows no errors but it dosen't display the msgbox when the drop is completed

 

any help will be greatly appreciated

 


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.SqlDataAdapter1.Fill(Me.DataSet11)
End Sub


Private Sub GridEX1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles GridEX1.MouseMove
'exit if no button is pressed
If e.Button = 0 Then Exit Sub

'exit if the cursor is inside the control's borders
If e.X >= 0 And e.X < GridEX1.Width AndAlso e.Y >= 0 AndAlso e.Y < GridEX1.Height Then
Exit Sub
End If

'the mouse is beign drag outside
'start the drag and drop operation

Dim myDataRowView As DataRowView
myDataRowView = CType(Me.GridEX1.GetRow().DataRow, System.Data.DataRowView)
Dim data As New DataObject()
data.SetData(myDataRowView)

'wait until the drag and drop operation is completed
Dim effect As DragDropEffects = DragDropEffects.Move
effect = GridEX1.DoDragDrop(data, effect)

'if the operation is a move then delete the row
'If effect = DragDropEffects.Move Then
'Dim myDataRow As DataRow
'myDataRow = CType(GridEX1.GetRow.DataRow(), DataRow)
'myDataRow.Delete()
'End If


End Sub

Private Sub ScheduleSummary1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ScheduleSummary1.DragDrop
' exit if data is not in the datarowview format
'If Not e.Data.GetDataPresent(System.Data.DataRowView) = True Then Exit Sub
Dim myDataRowView As DataRowView
If (TypeOf sender Is UserControls.ScheduleSummary) Then

myDataRowView = e.Data.GetData("DataRowView", True)
MsgBox(myDataRowView("FirstName") + " " + myDataRowView("LastName"))
End If

End Sub

Private Sub GridEX1_QueryContinueDrag(ByVal sender As Object, ByVal e As System.Windows.Forms.QueryContinueDragEventArgs) Handles GridEX1.QueryContinueDrag
If e.EscapePressed Then e.Action = DragAction.Cancel
End Sub


Private Sub ScheduleSummary1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ScheduleSummary1.DragEnter
e.Effect = e.AllowedEffect And DragDropEffects.Move
End Sub
End Class
[/Code]

 

Thanks in advanced,

 

Karim

You're either a one or a zero. Alive or dead.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...