Skip to content

Drag and Drop Urls in Windows Forms

Wed Mar 24 2004

So I wanted to allow for this, right? What if I find something on the net that just begs me to post it, and I want to use the url as the source for my post? Well, it's insanely easy...but you still have to wire it up a little bit. From the article I found (using google, of course), I changed the source code to this:


1 txtUrl_DragEnter( sender, System.Windows.Forms.DragEventArgs e) {
2 (e.Data.GetDataPresent(DataFormats.Text)){
3 e.Effect = DragDropEffects.All;
4 }
5 }
6
7 txtUrl_DragDrop( sender, System.Windows.Forms.DragEventArgs e) {
8 .txtUrl.Text = e.Data.GetData(DataFormats.Text).ToString();
9 }

where txtUrl is the url I want to use as a source for my post. Set AllowDrop = true in the designer, and you're good to go.

💾 May the source be with you. v3.2.419