Category / Section
What should to when I get a "DragDrop registration failed" error as I try to run the application containing the WinForms GridControl?
OLE drag and drop
The most likely cause of this problem is that your Main entry point does not have the [STAThread] attribute associated with it. Without this attribute, the Essential Grid support of the OLE Drag and Drop causes this error.
Solution:
There are two possible solutions. The first one is to add the [STAThread] attribute and remove the [MTAThread] attribute in case it is present. The second one is to remove the OLE Drag and Drop support from the Essential Grid.
Solution 1: Here is a sample Main entry point with the STAThread attribute.
[STAThread]
static void Main()
{
Application.Run(new Form1());
}<STAThread>
Shared Sub Main()
Application.Run(New Form1())
End SubSolution 2: To remove OLE Drag and Drop support so that your application can be MTAThread.
- Change the Main attribute [STAThread] to [MTAThread].
- Turn the AllowDrop off.
- Turn off the OLE options in the ControllerOptions.
- Set the DataObjectConsumerOptions to none.
[MTAThread]
static void Main()
{
Application.Run(new Form1());
}
//In Form_Load.
//Turns AllowDrop off.
this.gridControl1.AllowDrop = false;
//Turns off the OLE options in ControllerOptions
this.gridControl1.ControllerOptions -= GridControllerOptions.OleDataSource | GridControllerOptions.OleDropTarget;
//Sets DataObjectConsumerOptions value as “None”.
this.gridControl1.DataObjectConsumerOptions = GridDataObjectConsumerOptions.None;<MTAThread>
Shared Sub Main()
Application.Run(New Form1())
End Sub
'In Form_Load
'Turns AllowDrop off.
Me.gridControl1.AllowDrop = False
'Turns off the OLE options in ControllerOptions.
Me.gridControl1.ControllerOptions -= GridControllerOptions.OleDataSource Or GridControllerOptions.OleDropTarget
' Sets DataObjectConsumerOptions value as “None”.
Me.gridControl1.DataObjectConsumerOptions = GridDataObjectConsumerOptions.None