ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
<p><span style="font-size:16px;"><strong>AfterLabelEdit 事件(</strong></span><span style="font-size:16px;"><strong>ListView </strong></span><span style="font-size:16px;"><strong>和</strong></span><span style="font-size:16px;"><strong> TreeView </strong></span><span style="font-size:16px;"><strong>控件)</strong></span></p> <p><span style="line-height:1.78571;">在编辑当前被选中的 </span><b>Node </b><span style="line-height:1.78571;">或 </span><b>ListItem </b><span style="line-height:1.78571;">对象的标签之后该事件发生。</span></p> <p><span></span></p> <p class="label"><b>语法</b></p> <p><b>Private Sub</b> <span class="emp"><i>object_</i></span><b>AfterLabelEdit(</b><span class="emp"><i>cancel</i></span> <b>As Integer</b>, <span class="emp"><i>newstring</i></span> <b>As String)</b></p> <p>AfterLabelEdit 事件的语法包含下面部分:<span></span></p> <table class="MsoNormalTable" border="1" cellpadding="0"><tbody><tr><td width="29%" valign="top"><p class="MsoNormal"><b><span style="font-size:9.0pt;font-family:宋体;">部分</span></b><span style="font-size:9.0pt;font-family:宋体;"></span></p> </td> <td width="71%" valign="top"><p class="MsoNormal"><b><span style="font-size:9.0pt;font-family:宋体;">描述</span></b><span style="font-size:9.0pt;font-family:宋体;"></span></p> </td> </tr> <tr><td width="29%" valign="top"><p class="MsoNormal"><span class="emp"><i><span style="font-size:9.0pt;">object</span></i></span><span style="font-size:9.0pt;font-family:宋体;"></span></p> </td> <td width="71%" valign="top"><p class="MsoNormal"><span style="font-size:9.0pt;font-family:宋体;"><span>对象表达式</span></span><span style="font-size:9.0pt;font-family:宋体;">,其值是<span>“</span>应用于<span>”</span>列表中的一个对象</span><span style="font-size:9.0pt;font-family:宋体;"></span></p> </td> </tr> <tr><td width="29%" valign="top"><p class="MsoNormal"><span class="emp"><i><span style="font-size:9.0pt;">cancel</span></i></span><span style="font-size:9.0pt;font-family:宋体;"></span></p> </td> <td width="71%" valign="top"><p class="MsoNormal"><span style="font-size:9.0pt;font-family:宋体;">整数,它确定标签编辑操作是否被取消。任何非零整数取消该操作。也可以接受布尔值。</span><span style="font-size:9.0pt;font-family:宋体;"></span></p> </td> </tr> <tr><td width="29%" valign="top"><p class="MsoNormal"><span class="emp"><i><span style="font-size:9.0pt;">newstring</span></i></span><span style="font-size:9.0pt;font-family:宋体;"></span></p> </td> <td width="71%" valign="top"><p class="MsoNormal"><span style="font-size:9.0pt;font-family:宋体;">用户输入的字符串或<b><span> Null</span></b>,该值为 <b><span>Null </span></b>时表示用户取消了该操作<b>。</b></span><span style="font-size:9.0pt;font-family:宋体;"></span></p> </td> </tr> </tbody> </table> <p class="MsoNormal">&nbsp;</p> <p class="label"><b>说明</b></p> <p>只有在 <b><span>LabelEdit </span></b>属性被设置为<span> 0</span>(自动地)、或 <b><span>StartLabelEdit </span></b>方法被调用时,<span>AfterLabelEdit </span>与<span> BeforeLabelEdit </span>事件才发生。<span></span></p> <p>在完成编辑操作之后发生<span> AfterLabelEdit </span>事件。用户单击另一个 <b><span>Node </span></b>或 <b><span>ListItem</span></b>、或者按<span> ENTER </span>键的时刻,便是编辑操作完成的时刻。<span></span></p> <p>要取消标签的编辑操作,可以设置 <span class="emp"><i><span>cancel </span></i></span>为任何非零数或 <b><span>True</span></b>。如果标签的编辑操作被取消,则先前存在的标签被恢复。<span></span></p> <p>可用<span class="emp"><i><span> newstring </span></i></span>参数在取消操作之前进行条件测试。例如在下面的代码中,如果 <span class="emp"><i><span>newstring </span></i></span>是一个数则取消操作。</p> <p><br /> </p> <pre class="prettyprint lang-vb">Private Sub TreeView1_AfterLabelEdit(Cancel As Integer, NewString As String) If IsNumeric(NewString) Then MsgBox "No numbers allowed" Cancel = True End If End Sub</pre> <p><br /> </p>