Hi Dave,
In additional to gaidar's sample, when we drag an webbrowser item, e.g.a
picture or a link in the webpage, we will get a "HTML Format" or
"UniformResourceLocator" on the clipboard( this is how drag&drop work, it
is using the clipboard).
We can use the GetFormats to check which formats the dataobject that we
drag onto the form will support.
Debug.WriteLine("=============")
For Each fm As String In e.Data.GetFormats()
Debug.WriteLine(fm)'dump formats
Debug.WriteLine(e.Data.GetData(fm).ToString())' dump data
Next
Debug.WriteLine("=============")
'If we drag a link onto the form, we can use UniformResourceLocator to
retrieve the link data.
System.Text.Encoding.ASCII.GetString(CType(e.Data.GetData("UniformResourceLo
cator"),MemoryStream).ToArray())
output
:"
http://www.dotnet247.com/247reference/System/Windows/Forms/System.Windows.
Forms.aspx"
e.g.
drag a html image onto a form we will get the text as below. We need to
parse it ourselves.
Note the content in the <!--StartFragment--><!--EndFragment-->, it is what
we have selected.
Then we can use the WebClient or HttpWebresponse to restrieve the file from
the url.
We can figure out the url from the src and the SourceURL.
<!--StartFragment--><A href="/247reference/default.aspx"><IMG height=54
src="/247reference/i/l.gif"
width=182 border=0></A><!--EndFragment-->
[HTML Format dump]
Version:1.0
StartHTML:000000247
EndHTML:000000958
StartFragment:000000749
EndFragment:000000854
StartSelection:000000749
EndSelection:000000854
SourceURL:
http://www.dotnet247.com/247reference/System/Windows/Forms/Clipboa
rd/__discussions/3
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>.NET 247 : System.Windows.Forms.Clipboard Class
[Discussions]</TITLE><LINK
href="/247reference//DotNet247.css" type=text/css rel=stylesheet></HEAD>
<BODY leftMargin=0 topMargin=0 margintop="0" marginleft="0">
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD bgColor=#dfff0c>
<TABLE cellSpacing=0 cellPadding=10 width="100%">
<TBODY>
<TR>
<TD><!--StartFragment--><A href="/247reference/default.aspx"><IMG height=54
src="/247reference/i/l.gif"
width=182 border=0></A><!--EndFragment--></TD>
</TR>
</TBODY>
</TABLE>
</TD>
</TR>
</TBODY>
</TABLE>
</BODY>
</HTML>