Cancel
Showing results for 
Search instead for 
Did you mean: 

Drag and drop from parts library C#

Innovator
Innovator

Hello,


I want to drag a part document from parts library and drop it inside a assembly document with c#.
I tried this code but it did not work:

" private void textBox1_MouseDown(object sender, MouseEventArgs e)
{
isMouseDown = true;

}

private void textBox1_MouseMove(object sender, MouseEventArgs e)
{
textBox1.Text = @"C: \Users\PC\Desktop\Part1.par";
if (isMouseDown)
{
try
{
string[] files = new string[3];
files[0] = textBox1.Text;
DataObject data = new DataObject(DataFormats.FileDrop, files);
DoDragDrop(data, DragDropEffects.Copy);
}
catch (Exception ex)
{

MessageBox.Show(ex.Message);
}

}
}

private void textBox1_MouseUp(object sender, MouseEventArgs e)
{
isMouseDown = false;

}"

Does anyone have any sample code?
Thanks.

DragAndDrop.PNG

2 REPLIES 2

Re: Drag and drop from parts library C#

Solution Partner Genius Solution Partner Genius
Solution Partner Genius

I think I posted that code (or something similar).

That would be working if you were dragging from your own application form.

You dont need any programming to drag-drop from the library.

Maybe I don't get the idea...

Julian Guillo
Pixel Sistemas SL
Spain

Re: Drag and drop from parts library C#

Innovator
Innovator

@Julian Thank you for your reply but the code does not work even I draged the component from my form to the workspace unfortunately.