🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
<p><span style="line-height:1.78571;">这个属性返回或设置对 Node 或 ListItem 对象的引用,在光标移动到该对象上时,它就被突出显示为系统的突出颜色。</span></p> <p class="label" style="font-size:12px;">语法</p> <p><span class="emp"><i>object</i></span>.<span style="font-weight:700;">DropHighlight</span>&nbsp;[ =&nbsp;<span class="emp"><i>value</i></span>]</p> <p><span style="font-weight:700;">DropHighlight&nbsp;</span>属性的语法包含下面部分:</p> <table class="MsoNormalTable" border="1" cellpadding="0" style="width:650px;"><tbody><tr><td width="29%" valign="top"><p class="MsoNormal"><span style="font-weight:700;"><span style="font-size:9pt;font-family:宋体;">部分</span></span><span style="font-size:9pt;font-family:宋体;"></span></p> </td> <td width="71%" valign="top"><p class="MsoNormal"><span style="font-weight:700;"><span style="font-size:9pt;font-family:宋体;">描述</span></span><span style="font-size:9pt;font-family:宋体;"></span></p> </td> </tr> <tr><td width="29%" valign="top"><p class="MsoNormal"><span class="emp"><i><span style="font-size:9pt;">object</span></i></span><span style="font-size:9pt;font-family:宋体;"></span></p> </td> <td width="71%" valign="top"><p class="MsoNormal"><span style="font-size:9pt;font-family:宋体;">对象表达式</span><span style="font-size:9pt;font-family:宋体;">,其值是“应用于”列表中的一个对象。</span><span style="font-size:9pt;font-family:宋体;"></span></p> </td> </tr> <tr><td width="29%" valign="top"><p class="MsoNormal"><span class="emp"><i><span style="font-size:9pt;">value</span></i></span><span style="font-size:9pt;font-family:宋体;"></span></p> </td> <td width="71%" valign="top"><p class="MsoNormal"><span style="font-weight:700;"><span style="font-size:9pt;font-family:宋体;">Node&nbsp;</span></span><span style="font-size:9pt;font-family:宋体;">或&nbsp;<span style="font-weight:700;">ListItem&nbsp;</span>对象</span><span style="font-size:9pt;font-family:宋体;"></span></p> </td> </tr> </tbody> </table> <p class="MsoNormal">&nbsp;</p> <p class="label" style="font-size:12px;">说明</p> <p><span style="font-weight:700;">DropHighlight&nbsp;</span>属性一般在拖放操作中与&nbsp;<span style="font-weight:700;">HitTest&nbsp;</span>方法联用。在光标拖动到&nbsp;<span style="font-weight:700;">ListItem&nbsp;</span>或&nbsp;<span style="font-weight:700;">Node&nbsp;</span>对象上时,<span style="font-weight:700;">HitTest&nbsp;</span>方法返回对任何被拖到的对象的引用。接着,<span style="font-weight:700;">DropHighlight&nbsp;</span>属性被设置为点中的对象,同时返回对那个对象的引用。然后&nbsp;<span style="font-weight:700;">DropHighlight&nbsp;</span>属性就用系统突出颜色突出点中的对象。以下代码将&nbsp;<span style="font-weight:700;">DropHighlight&nbsp;</span>设置为用&nbsp;<span style="font-weight:700;">HitTest&nbsp;</span>方法点中的对象。</p> <p><br /> </p> <pre class="prettyprint lang-vb">Private Sub TreeView1_DragOver (Source As Control, X As Single, Y As Single, State As Integer) Set TreeView1.DropHighlight = TreeView1.HitTest(X,Y) End Sub</pre> <p><br /> </p> <p>在后面的&nbsp;DragDrop&nbsp;事件中用&nbsp;<span style="font-weight:700;">DropHighlight&nbsp;</span>属性返回对源控件最终落在其上的对象的引用,如以下代码所示:</p> <p><br /> </p> <pre class="prettyprint lang-vb">Private Sub TreeView1_DragDrop (Source As Control, x As Single, y As Single) 'DropHighlight 返回对拖放操作发生在其上的对象的引用。 Me.Caption = TreeView1.DropHighlight.Text '为了释放 DropHighlight 引用,将它设置为 Nothing。 Set TreeView1.DropHighlight = Nothing End Sub</pre> <p><br /> </p> <p>注意,在前面的例子中,在过程完成之后,<span style="font-weight:700;">DropHighlight&nbsp;</span>属性被设置为&nbsp;Nothing。为了释放突出效果必须这样做。</p> <p><br /> </p>