I feel stupid asking this, but could someone just tell me how I would use the drag and drop feature? I want the users to be able to drag a bunch of files over into a MDI form
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB ) VB.NET to C# conversion tips!!
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.
I've just seen Edneeis' response. That thread resolution seems a lot simpler than mine. Let us know if it works.
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.
Thanks all... kinda busy today but will look at this over the weekend again
Edneeis, I almost forgot there is a search button thanks
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB ) VB.NET to C# conversion tips!!
Originally posted by thephantom I actually wrote a utiiliity using the drag/drop functionality. I will post my code in the morning when I get to work.
Basically though, you set the control property "allow drop" to true
and in the "dragLeave" or dragdrop event, that's where you get the action.
would you post it then?
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB ) VB.NET to C# conversion tips!!
sorry it took so long to post. I couldn't locate the file. When anyone downloads this file, you'll need to go through and alter some of the code because it was written with some hard-coding.
Originally posted by thephantom sorry it took so long to post. I couldn't locate the file. When anyone downloads this file, you'll need to go through and alter some of the code because it was written with some hard-coding.
thanks, got it working
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB ) VB.NET to C# conversion tips!!
I downloaded the Drag drop project you quoted and, of course it works fine .......BUT Could you please tell me how the drag event of txtLowerRight is fired?
The code which is fired is in the sub
VB Code:
Private Sub TextBoxLowerRight_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms
How is this sub called?
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.
I downloaded the Drag drop project you quoted and, of course it works fine .......BUT Could you please tell me how the drag event of txtLowerRight is fired?
The code which is fired is in the sub
VB Code:
Private Sub TextBoxLowerRight_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms
How is this sub called?
highlight the "Source Text" and drag that text over it. It gets fired after the DragEnter event is fired. If e.Effect isnt modified or is set to e.Effect = DragDropEffects.None in the DragEnter event, then the DragDrop event wont be fired
thanks phantom for the sample
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB ) VB.NET to C# conversion tips!!
"highlight the "Source Text" and drag that text over it. It gets fired after the DragEnter event is fired. If e.Effect isnt modified or is set to e.Effect = DragDropEffects.None in the DragEnter event, then the DragDrop event wont be fired"
Sorry, I did not make myself clear but I have just noticed the answer!!
I was wondering why the drag/drop method of txtLowerRight fired the sub TextBoxLowerRight_DragDrop but I now notice that the handle of the sub refers to txtLowerRight and looking at other threads I notice that you can have more than one event firing a sub by adding handles.
Many thanks. I'm learning slowly (and sometimes painfully
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.
"highlight the "Source Text" and drag that text over it. It gets fired after the DragEnter event is fired. If e.Effect isnt modified or is set to e.Effect = DragDropEffects.None in the DragEnter event, then the DragDrop event wont be fired"
Sorry, I did not make myself clear but I have just noticed the answer!!
I was wondering why the drag/drop method of txtLowerRight fired the sub TextBoxLowerRight_DragDrop but I now notice that the handle of the sub refers to txtLowerRight and looking at other threads I notice that you can have more than one event firing a sub by adding handles.
Many thanks. I'm learning slowly (and sometimes painfully
sorry I didnt understand your question either....
btw if you have one sub which handles more than one controls' event, try to pick a general name for it. For example if txtRight_TextChanged handles the event for 3 textboxes then I would say you better change the sub name to something else, like txtPositions_TextChanged
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB ) VB.NET to C# conversion tips!!