问题描述
我有一个带有列表框和树视图的 winform.
I have a winform with a listbox and a treeview.
一旦我的列表框充满了项目,我想将它们(多个或单个)从列表框中拖放到树视图中的一个节点中.
Once my listbox is filled with items, I want to drag them (multiple or single) from the listbox and drop them in a node in the treeview.
如果有人在 C# 中有一个很好的例子,那就太好了.
If somebody has a good example in C# that would be great.
推荐答案
我已经有一段时间没有搞乱拖放了,所以我想我会写一个快速的示例.
It's been a while since I've messed with Drag/Drop so I figured I'll write a quick sample.
基本上,我有一个表单,左侧是列表框,右侧是树视图.然后我在上面放了一个按钮.单击按钮时,它只是将接下来十天的日期放入列表框中.它还使用 2 个父节点和两个子节点填充 TreeView.然后,您只需处理所有后续的拖放事件即可使其正常工作.
Basically, I have a form, with a listbox on the left, and a treeview on the right. Then I put a button on top. When the button is clicked, it just puts the date of the next ten days into the list box. It also populates the TreeView with 2 parents nodes and two child nodes. Then, you just have to handle all the subsequent drag/drop events to make it work.
这篇关于C# 拖动 &从列表框拖放到树视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!