|
-
Feb 18th, 2004, 03:17 AM
#3
PowerPoster
HI,
Not sure what you are asking.
You don't drop files on to forms as such. You load files into your application and then display their contents, e.g. data in a Datagrid or text in a TextBox etc.
I do not think there is any automatic drag/drop in .NET (there was in VB6) and it has to be coded. To give you a start, the following creates the collect & drag part for a TextBox. Try the MSDN for the remaining code to prepare the target
If you want to drag and drop the contents of a TextBox, etc, you:
set the AllowDrop property of the target to true
write code to detect the intention to drag/drop e.g. in the MouseMove event of the source TextBox
If e.Button=0 then exit sub (if no button is pressed)
Create a new DataObject instance to hold the contents of the source and exit if no data to be dragged
Dim txtTemp as TextBoxBase=DirectCast(sender, TextBoxBase)
if txtTemp.TextLength = 0 then Exit Sub
if e.x>=0 and e.x < txtTemp.Width and e.y>=0 and e.y<tbase.height Exit Sub (check if cursor is still inside control's borders)
Dim datTemp as new DataObject()
if txtTemp.SelectionLength>0 then
datTemp.SetData(dataFormats.text, txtTemp.SelectedText
Else
datTemp.SetData(dataFormats.text, txtTemp.Text
end if
start the drag operation & wait until it is completed
Dim effect as DragDropEffects = DragDropEffects.Copy or DragDropEffects.Move
effect=txtTemp.DoDragDrop(datTemp, effect)
Delete source contents if required
If effect = DragDropEffects.Move Then
If txtTemp.SelectionLength > 0 then
txtTemp.Text = ""
Else
txtTemp.Text = ""
End if
End if
Hope I have not done any typos!!
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
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
|