On Feb 7, 12:05*pm, "Griff" <GriffithsJ_... @htomail.comwro te:
What makes you think that the events do not appear to fire? Do you
have a debug.writeline in them?
Yes. *I have break-points (also tried message boxes etc). *I'm certainthe
events don't fire.
XAML for the text box is as follows:
<TextBox HorizontalConte ntAlignment="Le ft" Margin="146,13, 12,0"
Name="txtFile" AllowDrop="True " Height="25" VerticalAlignme nt="Top">
<TextBox.Bitmap Effect>
<OuterGlowBitma pEffect />
</TextBox.BitmapE ffect>
</TextBox>
I only replied because I just recently figured out for the first time
how Drag and Drop works in .NET. I really can'y say why the event's
don't seem to be firing. You mention that you set the AllowDrop for
the TextBox, but are you sure you enabled it for the form as well?
Here is the working code from my application's form that makies use of
DragDrop when editing a SQL Query:
Private Sub txtQuery_DragEn ter(ByVal sender As Object, ByVal e As
System.Windows. Forms.DragEvent Args) Handles txtQuery.DragEn ter
Dim fi As FileInfo
Dim sFiles As String()
If e.Data.GetDataP resent(DataForm ats.FileDrop) Then
sFiles = CType(e.Data.Ge tData(DataForma ts.FileDrop),
String())
fi = New FileInfo(sFiles (0))
If fi.Extension.To Upper = ".SQL" Then
If sFiles.GetUpper Bound(0) = 0 Then
e.Effect = DragDropEffects .Copy
Else
e.Effect = DragDropEffects .None
End If
Else
e.Effect = DragDropEffects .None
End If
Else
e.Effect = DragDropEffects .None
End If
End Sub
Private Sub txtQuery_DragDr op(ByVal sender As Object, ByVal e As
System.Windows. Forms.DragEvent Args) Handles txtQuery.DragDr op
Dim myReader As StreamReader
Dim sFiles As String()
If e.Data.GetDataP resent(DataForm ats.FileDrop) Then
sFiles = CType(e.Data.Ge tData(DataForma ts.FileDrop),
String())
myReader = New StreamReader(sF iles(0))
txtQuery.Text = myReader.ReadTo End
myReader.Close( )
End If
End Sub