We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How do I make the HTMLUI control to load html documents by dragging and dropping them on the control ?

Platform: WinForms |
Control: HTMLUIControl |
Published Date: April 30, 2011 |
Last Revised Date: July 10, 2014


HTMLUI control is made to support various events related to the drag drop operation.

The Allowdrop property of the HTMLUI control should be made to true, this helps in supporting the drag drop operation on the control.

The DataFormats and the DragDropEffects should be decided to determine the action of the DragDrop event. These formats and effects can be got or set with the help of the DragEvent arguments.

During DragDrop, the file name of the document along with the location is collected and when the mouse button is released, the specified document is loaded from the mentioned location through the LoadHTML method of the HTMLUI control.


//To support drag events to the control

this.htmluiControl1.AllowDrop = true;

//DragDrop and DragEnter events declaration

this.htmluiControl1.DragDrop += new System.Windows.Forms.DragEventHandler(this.htmluiControl1_DragDrop);

this.htmluiControl1.DragEnter += new System.Windows.Forms.DragEventHandler(this.htmluiControl1_DragEnter);

private void htmluiControl1_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)


if(e.Data.GetDataPresent (DataFormats.FileDrop))

//Specifying the drop effect

e.Effect = DragDropEffects.All;


e.Effect = DragDropEffects.None;


private void htmluiControl1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)


//Specifying the drop format and collecting the file name

string[] files = (string[])e.Data.GetData("FileDrop", false);

foreach (string fileName in files)


//Loading the specified file in to the HTMLUI control





'To support drag events to the control

Private Me.htmluiControl1.AllowDrop = True

'DragDrop and DragEnter events declaration

Private Me.htmluiControl1.DragDrop += New System.Windows.Forms.DragEventHandler(Me.htmluiControl1_DragDrop)

Private Me.htmluiControl1.DragEnter += New System.Windows.Forms.DragEventHandler(Me.htmluiControl1_DragEnter)

Private Sub htmluiControl1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs)

If e.Data.GetDataPresent (DataFormats.FileDrop) Then

'Specifying the drop effect

e.Effect = DragDropEffects.All


e.Effect = DragDropEffects.None

End If

End Sub

Private Sub htmluiControl1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs)

'Specifying the drop format and collecting the file name

Dim files As String() = CType(e.Data.GetData("FileDrop", False), String())

For Each fileName As String In files

'Loading the specified file in to the HTMLUI control


Next fileName

End Sub

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon