I tried it but not successful.please help me
CODE
Public Class Form1
Dim WithEvents mydoc As System.Windows.Forms.HtmlDocument
Dim mylink As System.Windows.Forms.HtmlElement
Dim str As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
WebBrowser1.Navigate("www.youtube.com")
End Sub
Private Sub Button1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Button1.DragDrop
Dim wb As WebBrowser
wb = CType(sender, WebBrowser)
str = getContent(mydoc.Url.AbsoluteUri.ToString)
(I dont know what to write in below line)
'Button1.Image = e.Data.GetData(DataFormats.StringFormat)
End Sub
Private Sub Button1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Button1.DragEnter
Button1.AllowDrop = True
e.Effect = e.AllowedEffect
End Sub
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
Try
mydoc = WebBrowser1.Document
mydoc.AttachEventHandler("OnMouseDown", AddressOf mylink_MouseDown)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub mylink_MouseDown(ByVal sender As Object, ByVal e As EventArgs)
Try
Dim wb As WebBrowser
wb = CType(sender, WebBrowser)
wb.DoDragDrop(wb.Document, DragDropEffects.Copy)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Function getContent(ByVal url As String) As String
Dim buffer As String
Try
Dim req As HttpWebRequest = CType(WebRequest.Create(url), HttpWebRequest)
req.AllowWriteStreamBuffering = True
Dim resp As HttpWebResponse = CType(req.GetResponse(), HttpWebResponse)
Dim sr As StreamReader = New StreamReader(resp.GetResponseStream())
buffer = sr.ReadToEnd()
sr.Close()
Catch exp As Exception
buffer = "Error: " + exp.Message.ToString()
End Try
Return buffer
End Function
End Class