开发者

Drag n Drop in a list view within is own columns (.net)

I was just wondering, if I have a list view control, with 2 columns, and insert items to those columns, ex:

Animal.................. Car

Dog------------------ 开发者_StackOverflow中文版 Ford Foucs

Cat------------------- Subaru Rally

Bull------------------- Lambo Gallardo

Could I Select an item from One column and put in the other, ex. (Selecting lambo gallardo and drag drop it to 'Animal Column'

Animal.................. Car

Dog------------------ Ford Foucs

Cat------------------- Subaru Rally

Bull

Lambo Gallardo

My GOAL is to NOT use a lot of listviews controls to interact from one col to another. Like a drag and drop function between multiple columns.

I have found a lot of examples but they only are between from one listview to another. Have you tried This? I want to do this in vb.net.

Update 08/17/2011 To answer Jonsca: I've done the long, dreadful solution: Create different list views controls.

Private Sub ListView_DragDrop(ByVal sender As Object, ByVal e As _
System.Windows.Forms.DragEventArgs) Handles list1.DragDrop, _
list2.DragDrop, list3.DragDrop, listN.DragDrop 

and some more for the Itemdrag and dragenter events. Got some ideas to kill this code?


You could elect to monitor an ItemDrag event for when you hold down the mouse over the right column and drag, but the only problem is that the sender would be the entire ListViewItem (i.e., Dog and FordFocus). This may not be a problem for two columns (for that case to move the item, you would delete the first SubItem (FordFocus) of that ListViewItem and start a new ListViewItem programmatically, with FordFocus as the text, and no subitems.

Thus, this would only work going from column 2 to column 1, and not in reverse. With a third column, you would not be able to distinguish which of column 2 or column 3 you were selecting.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜