[VB.NET] - ListBox Drag & Drop - [TUT] - Printable Version +- Support Forums (https://www.supportforums.net) +-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87) +--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18) +---- Forum: Visual Basic and the .NET Framework (https://www.supportforums.net/forumdisplay.php?fid=19) +---- Thread: [VB.NET] - ListBox Drag & Drop - [TUT] (/showthread.php?tid=21521) Pages:
1
2
|
[VB.NET] - ListBox Drag & Drop - [TUT] - Fragma - 08-18-2011 Not really a tutorial, more just a simple guide. People love programs which are simple and easy to use, which is why the whole drag & drop feature is so big lately. The following snippets of code will allow users to drag files from their computer, directly into your ListBox control, like so... Firstly, under your ListBox properties, set AllowDrop to True. Under your ListBox's DragOver event, add the following: Code: If e.Data.GetDataPresent(DataFormats.FileDrop) Then The above code simply determines what is happening when a file is dragged over the ListBox control. Next up, add the following to the ListBox's DragDrop event: Code: Dim file As String() = DirectCast(e.Data.GetData(DataFormats.FileDrop, True), System.String()) This gets the data of the file(s) and adds the location as an Item into your ListBox. I've also set a restriction on it, so that only .mp3 files can be added, although this can be removed/edited to fit your needs. Hope this helps some of you. RE: [VB.NET] - ListBox Drag & Drop - [TUT] - AceInfinity - 08-18-2011 If you wanted to be fancy you could do this with sorting the parts of the filepath string out to get the file format, filename, and directory location into 3 different segments, or use a listbox with 3 columns for those items on every dragdrop RE: [VB.NET] - ListBox Drag & Drop - [TUT] - 0ld_F4T_N!gg4™ - 08-22-2011 Nice detailed and helpful tutorial. I hope to see more like this. Thanks for the share. RE: [VB.NET] - ListBox Drag & Drop - [TUT] - Hell Guardian - 08-24-2011 This is nice it could be helpful for beginners, Good Job RE: [VB.NET] - ListBox Drag & Drop - [TUT] - LiveModz - 08-25-2011 Thanks for this tutorial, i will use this for something i am making. RE: [VB.NET] - ListBox Drag & Drop - [TUT] - Digital-Punk - 08-25-2011 Thanks for the share this is actually very useful. RE: [VB.NET] - ListBox Drag & Drop - [TUT] - Nirmal - 08-25-2011 Thanks For This Guide. I Never Seen This Trick Anywhere Else. RE: [VB.NET] - ListBox Drag & Drop - [TUT] - AceInfinity - 08-25-2011 I've got one that will drag and drop files with multiple columns to a listview if anyone wants that, i'll post it up at some point. RE: [VB.NET] - ListBox Drag & Drop - [TUT] - Digital-Punk - 08-25-2011 Cool man I would like to take a peak at that thanks again. RE: [VB.NET] - ListBox Drag & Drop - [TUT] - The Flash - 08-25-2011 I don't get what the point is of this... Sorry! |