By Adam Nagy
You may want to provide a user control with a list of components that you could drag & drop onto Inventor. In case of .NET it's quite easy to set up. You just have to handle the MouseDown event of the control from which you want to enable the Drag & Drop, and then set up the data that could be dragged onto another applications.
In this case we have a simple .NET Form with a button on it named myButton with text "Drag Me!". If the user starts dragging this button then it will drag a file onto other applications like Inventor, which accept such a thing.
Here is the main part of the C# source code:
using System.Collections.Specialized;
using System.Windows.Forms;
namespace DragAndDropTest
{
public partial class MyForm : Form
{
public MyForm()
{
InitializeComponent();
}
private void myButton_MouseDown(
object sender, MouseEventArgs e)
{
DataObject dragInfo = new DataObject();
StringCollection coll = new StringCollection();
coll.Add(@"c:\temp\test.ipt");
dragInfo.SetFileDropList(coll);
// "Copy" will let us open the ipt
// "Link" will let us insert the ipt in an assembly
myButton.DoDragDrop(
dragInfo,
DragDropEffects.Copy | DragDropEffects.Link);
}
}
}
Here it is in action: