-
ListView drag data
I'm trying to drag a ListViewItem out of a ListView, and then drop it on another ListView. Having troubles retrieving the ListViewItem. It works fine if the data is text (like all the examples use). Even though GetDataPresent seems to indicate that the data is a ListViewItem, for the life of me, I can't figure out the syntax to retrieve the ListViewItem.
Am I missing something, or is this just not possible?
-
Thanks to some VB.NET code I found here, I can pass my ListViewItem object and retrieve it. Some relevant code:
PHP Code:
private void lvActiveOfficers_ItemDrag(object sender, System.Windows.Forms.ItemDragEventArgs e)
{
lvActiveOfficers.DoDragDrop(e.Item, DragDropEffects.Copy);
}
private void lvActiveUnits_DragOver(object sender, System.Windows.Forms.DragEventArgs e)
{
if (e.Data.GetDataPresent("System.Windows.Forms.ListViewItem"))
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
private void lvActiveUnits_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
ListViewItem lvItem = (System.Windows.Forms.ListViewItem)e.Data.GetData("System.Windows.Forms.ListViewItem");
MessageBox.Show(lvItem.SubItems.Count.ToString());
}