-
March 7th, 2012, 01:55 AM
#1
DragDrop on Button child class
I created a class inheriting from the button class. I'm trying to make it run some code when I drag a file on the button.
The Problem: Nothing happens, like if the event was never raised
I tried the event on a regular button and it works just fine. But when I try it in my custom class it doesn't work
DragEnter, DragLeave and Click work.
Here's part of my code :
Public Class soundButton
Inherits Button
Public spacing As Integer = 6
Public soundFile As String
Public sound As Microsoft.DirectX.AudioVideoPlayback.Audio
Private Sub DragEffect(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Me.DragEnter
If (e.Data.GetDataPresent(DataFormats.FileDrop)) Then
e.Effect = DragDropEffects.All
End If
End Sub
Private Sub soundButton_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Me.DragDrop
MsgBox("It works")
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
//Do stuff
End If
End Sub
Public Sub New(ByVal row, ByVal column)
Me.Width = Form1.soundButtonRef.Width
Me.Height = Form1.soundButtonRef.Height
Me.Location = New Point(row * (Me.Width + spacing) + spacing + 6, column * (Me.Height + spacing) + spacing + 6)
Me.AllowDrop = True
Form1.Controls.Add(Me)
Me.Show()
End Sub
End Class
Thanks for your help
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|