Note: Advice in this article will only work for DotNetBrowser 1.
Since 1.11 it is possible to obtain extended data about the dragged files. It is possible to work with data through the IDataObject
instance. To turn this feature on, you should set the Chromium switch "--enable-com-in-drag-drop"
to enable COM object transfer.
The following sample code demonstrates how to handle OnDragEnterEvent
and work with the bound IDataObject
instance:
C#
private void OnDragEnterEvent(object sender, DragDropEventArgs e) { string[] filenames = null; //Check if the source COM object present if (e.DataObject != null) { //Create System.Windows.DataObject for source COM IDataObject DataObject dataObject = new DataObject(e.DataObject); //Create Outlook wrapper OutlookDataObject dataObject = new OutlookDataObject(dataObject); //Get needed data filenames = (string[])dataObject.GetData("FileGroupDescriptorW"); } }
VB.NET
Private Sub OnDragEnterEvent(ByVal sender As Object, ByVal e As DragDropEventArgs) Dim filenames As String() = Nothing 'Check if the source COM object present If e.DataObject IsNot Nothing Then 'Create System.Windows.DataObject for source COM IDataObject Dim dataObject As DataObject = New DataObject(e.DataObject) 'Create Outlook wrapper Dim dataObject As OutlookDataObject = New OutlookDataObject(dataObject) 'Get needed data filenames = CType(dataObject.GetData("FileGroupDescriptorW"), String()) End If End Sub
Note: The
IDataObject
instance exists only in the scope of theDragEnterEvent
handler. For theDropEvent
andDragExitEvent
thee.DataObject
property is expected to return null.