我想使用兩個Listviews(AllListView和PreListView)之間的拖放。這是我沒走多遠:Listviews和拖放在C#
在該AllListView裝滿物品的功能,我用類似的東西assosiate的myCustomDataObject到單個ListViewItem的:
ListViewItem newItem = new ListViewItem();
newItem.Text = myCustomDataObject.getName();
newItem.Tag = myCustomDataObject;
lst_All.Items.Add(newItem);
有我的事件處理程序2名列表視圖:
AllListView:
private void OnAllDragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.All;
// How Do I add my CustomDataObject?
}
private void OnAllItemDrag(object sender, ItemDragEventArgs e)
{
base.DoDragDrop(lst_All.SelectedItems[0], DragDropEffects.Move);
// Do I have to Do something to pass my CustomDataObject?
}
PreListView:
private void OnPreDragEnter(object sender, DragEventArgs e)
{
//If there one of myCustomDataObject go on
e.Effect = DragDropEffects.Move;
}
private void OnPreDragDrop(object sender, DragEventArgs e)
{
// Get Here myCustomDataObject to generate the new Item
lst_Pre.Items.Add("Done...");
}
所以我的問題是,如何實現myCustomDataObject在「OnPreDragDrop」中找到。我已經嘗試了e.Data.Getdata()和e.Data.Setdata()的許多版本,但我沒有太多的瞭解。
**謝謝!!! – Tagamoga