Windows Develop Bookmark and Share   
 index > Windows Forms General > How to simulate the action : drag-drop a item from a listbox to another?
 

How to simulate the action : drag-drop a item from a listbox to another?

Hi everyone,
I want to simulate the action : drag-drop a item from a listbox to another.

Thanks a lot in advance!
  • Moved byNancy ShaoMSFTWednesday, September 09, 2009 2:27 AMTo get better support (From:Visual C++ General)
  •  
Tommy_Guo  Monday, September 07, 2009 7:45 AM

Hi,

We always implement dragging and dropping by handling these events:

MouseDown event: record the index which will be moved.

DragOver event

DragDrop event: remove the item in the old listbox. Insert the item to the new listbox.

ListBox.IndexFromPoint(x,y) method can detect the item index.

More information:

Drag and Drop between list boxes - Beginner's Tutorial

http://www.codeproject.com/KB/dotnet/csdragndrop01.aspx

Control.DragDrop Event

http://msdn.microsoft.com/en-us/library/system.windows.forms.control.dragdrop.aspx

If there anything unclear, please feel free to tell me.

Best regards,

Ling Wang


Please remember to click “Mark as Answer�on the post that helps you, and to click “Unmark as Answer�if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Ling Wang  Monday, September 14, 2009 7:27 AM
Hi Tommy,

Based on my understanding, this issue is more related to Windows Forms, so I'm moving this thread to "Windows Forms General" Forum for better support.

Best Regards,
Nancy
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Nancy Shao  Wednesday, September 09, 2009 2:25 AM

Hi,

We always implement dragging and dropping by handling these events:

MouseDown event: record the index which will be moved.

DragOver event

DragDrop event: remove the item in the old listbox. Insert the item to the new listbox.

ListBox.IndexFromPoint(x,y) method can detect the item index.

More information:

Drag and Drop between list boxes - Beginner's Tutorial

http://www.codeproject.com/KB/dotnet/csdragndrop01.aspx

Control.DragDrop Event

http://msdn.microsoft.com/en-us/library/system.windows.forms.control.dragdrop.aspx

If there anything unclear, please feel free to tell me.

Best regards,

Ling Wang


Please remember to click “Mark as Answer�on the post that helps you, and to click “Unmark as Answer�if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Ling Wang  Monday, September 14, 2009 7:27 AM

You can use google to search for other answers

Custom Search

More Threads

• ToolStripButton and MDI
• Accessing Windows controls from another class
• Zoom to a user-selected region
• Application Settings User Scope
• Update
• IMessageFilter cannot catch WM_CLOSE message
• Column cannot be added because its CellType property is null
• WebBrowser control in VB.Net
• GDI help
• How to close child form