在DragDrop事件中如何确定放置的Item是从哪个控件拖动过来的? 情形描述:有一个Treeview和两个Listview。操作中都会有将listview中的Listitem拖放到treeview中,在treeview的dragdrop事件中如何确定到底是从哪个listview中拖过来的。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 dragdrop事件有一个source参数,可以使用它判断:if source is tree1 then...elseif source is tree2 then...endif 在treeview的dragdrop事件中判断:if source is listview1 then do somethingelseif source is listview2 then do somethingendif if source is tree1 then...elseif source is tree2 then...endif 我用到的事件是OLEDragDrop,这个事件里没有source参数的。 1>可以先声明一个的枚举变量:Enum DragSource cNone=0 cTreeview1=1 cListView1=2 cListView2=3End Enum2>定义Private dSource as DragSource3> 在TreeView1_OLEStartDrag 中 dSource=cTreeview1 在ListView1_OLEStartDrag 中 dSource=cListView1 在ListView2_OLEStartDrag 中 dSource=cListView24> 在三个控件的OLEDragDrop事件中判断dSourse的值即可知道拖拽来源,结束后: dSource=cNone上面是一个思路,我一般是这么做的,不知道是否合适? 这个思路我看基本上行,谢谢。sworddx(.:RNPA:. Hillinsilence;剑宇潇湘·秋叶原 Reloaded),在什么情况下可能会产生意外情况。 例如,从外源(不是从本程序的控件开始)进行OLE拖动,得到的dSource就会不对。不过就你的应用环境来看,这个担心可能是多余的。 怎么实现treeview中拖放节点 怎么把GMT时间转换成一般时间格式 寻一思路(快进来) VB代码分享 完美支持98、2000系统自定义打印纸张 创建数据库问题 谁能说说vb与vb.net,vc与vc.net,C#与vc.net的关系,区别和本质吗! 知道如何设置 MSHFlexGrid1 的列标头居中吗? 在VB中,如何取得一个文件的创建或更新时间?100求救!!! 如何得到当前网络连接的名字? 如何去掉不规则窗体拖动时讨厌的边框? 怎么打开系统的控制面板? 求一sql语句的写法
if source is tree1 then
...
elseif source is tree2 then
...
endif
if source is listview1 then
do something
elseif source is listview2 then
do something
endif
...
elseif source is tree2 then
...
endif
Enum DragSource
cNone=0
cTreeview1=1
cListView1=2
cListView2=3
End Enum2>定义
Private dSource as DragSource3> 在TreeView1_OLEStartDrag 中 dSource=cTreeview1
在ListView1_OLEStartDrag 中 dSource=cListView1
在ListView2_OLEStartDrag 中 dSource=cListView2
4> 在三个控件的OLEDragDrop事件中判断dSourse的值即可知道拖拽来源,
结束后: dSource=cNone上面是一个思路,我一般是这么做的,不知道是否合适?
sworddx(.:RNPA:. Hillinsilence;剑宇潇湘·秋叶原 Reloaded),在什么情况下可能会产生意外情况。