I did some research and found this :
DataObject d = new DataObject();
d.SetData(DataFormats.Serializable, myObject);
d.SetData(DataFormats.Text, myObject.ToString());
myForm.DoDragDrop(d, DragDropEffects.Copy);
code snippet to drag drop in win forms.
And i tried implementing it like this (WPF) :
private void listView1_MouseMove(object sender, MouseEventArgs e)
{
try
{
if (e.LeftButton == MouseButtonState.Pressed)
{
DataObject d = new DataObject();
d.SetData(DataFormats.Serializable, listView1.SelectedItem);
d.SetData(DataFormats.Text, listView1.SelectedItem.ToString());
DragDrop.DoDragDrop(listView1, d, DragDropEffects.Copy);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Now I had thought when i drag dropped the ListViewItem into notepad it would probably copy the class name of the selected item (Because that’s what listView1.SelectedItem.ToString()) is… But instead Notepad showed a picture of a cancel symbol while hovering, and copied nothing when i let go of the mouse button.
The over all goal of this is to change the class into a comma delimited string so when it copy pastes into notepad all of the data of the class will be in a nice format.
But if someone could help me just get the class name to copy i’m sure i could figure it out from there 😮
So…. Yea.
After much bashing of poor notepad technology, c# comes out victorious <.<