samisammour
Programmer
I'm trying to do an drag and drop example but it failed.
my code is:
public partial class Form1 : Form
{
[tab]private String f;
[tab]public Form1()
[tab]{
[tab][tab]InitializeComponent();
[tab][tab]f = "D:\\Special";
[tab][tab]String[] files = Directory.GetFiles( f );
[tab][tab]foreach ( String fi in files )
[tab][tab]{
[tab][tab][tab]listView1.Items.Add( fi );
[tab][tab]}
[tab]}
[tab]private void listView1_ItemDrag( object sender, ItemDragEventArgs e )
[tab]{
[tab][tab]DoDragDrop( new DataObject( DataFormats.FileDrop, ( ( ListViewItem ) e.Item ).Text ), DragDropEffects.Copy );
[tab]}
}
The problem is when I drag an item from the listview to any other place it doesn't work, I have searched a lot and I couldn't solve this.
Please help me, it's very urgent.
my code is:
public partial class Form1 : Form
{
[tab]private String f;
[tab]public Form1()
[tab]{
[tab][tab]InitializeComponent();
[tab][tab]f = "D:\\Special";
[tab][tab]String[] files = Directory.GetFiles( f );
[tab][tab]foreach ( String fi in files )
[tab][tab]{
[tab][tab][tab]listView1.Items.Add( fi );
[tab][tab]}
[tab]}
[tab]private void listView1_ItemDrag( object sender, ItemDragEventArgs e )
[tab]{
[tab][tab]DoDragDrop( new DataObject( DataFormats.FileDrop, ( ( ListViewItem ) e.Item ).Text ), DragDropEffects.Copy );
[tab]}
}
The problem is when I drag an item from the listview to any other place it doesn't work, I have searched a lot and I couldn't solve this.
Please help me, it's very urgent.