多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
<p><strong><span style="font-size:16px;">GotFocus 事件</span></strong></p> <p>当对象通过用户操作(如标签或点击对象)或通过使用SetFocus方法更改代码中的焦点来收到对象时发生。只有当所有可见控件被禁用时,窗体才会接收焦点。</p> <p><br /> </p> <p><span></span></p> <p class="label"><b>语法</b></p> <p><b></b></p> <p style="color:#2A2A2A;font-family:'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif;font-size:13px;"><b><b>Private Sub Form_GotFocus(&nbsp;)</b></b></p> <p style="color:#2A2A2A;font-family:'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif;font-size:13px;"><b><b>Private Sub&nbsp;</b><i>Object</i><b>_GotFocus(</b>[<i>index</i>&nbsp;<b>As Integer</b>]<b>)</b></b></p> <p style="color:#2A2A2A;font-family:'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif;font-size:13px;"><b><b><br /> </b></b></p> <b></b><p><br /> </p> <p>GotFocus&nbsp;事件的语法包含下面部分:<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;">index</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 style="color:#2A2A2A;font-family:'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif;font-size:13px;line-height:17.55px;">一个整数,唯一标识一个控件,如果它在一个控制数组。</span></span></p> </td> </tr> </tbody> </table> <p class="MsoNormal"><br /> </p> <p class="label"><b>说明</b></p> <p><br /> </p> <p>通常,您使用GotFocus事件过程来指定控件或窗体首次接收焦点时发生的操作。例如,通过将GotFocus事件过程附加到窗体上的每个控件,您可以通过显示简要说明或状态栏消息来指导用户。您还可以通过启用,禁用或显示依赖于具有重点的控件的其他控件来提供可视提示。</p> <blockquote class="dtBlock" style="color:#000000;font-family:'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif;font-size:13px;"><b class="le">注意</b>&nbsp;&nbsp;&nbsp;&nbsp;只有当对象的<b>Enabled</b>和<b>Visible</b>属性设置为<b>True时,</b>对象才能接收焦点。要在Visual Basic中自定义键盘界面以移动焦点,请设置选项卡顺序或指定窗体上控件的访问键。</blockquote> <h4 class="dtH4" style="color:#000000;font-size:1.077em;font-family:'Segoe UI Semibold', 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif;font-weight:normal;">例:<span style="color:#2A2A2A;font-family:'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif;font-size:13px;line-height:1.78571;">此示例在</span><b>OptionButton</b><span style="color:#2A2A2A;font-family:'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif;font-size:13px;line-height:1.78571;">组中的</span><b>按钮</b><span style="color:#2A2A2A;font-family:'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif;font-size:13px;line-height:1.78571;">获得焦点时显示状态栏消息。</span></h4> <p><br /> </p> <pre class="prettyprint lang-vb">Private Sub Form_Load () &nbsp; &nbsp;Label1.AutoSize = True End Sub Private Sub OptionGroup_GotFocus (Index As Integer) &nbsp; &nbsp;Select Case Index &nbsp; &nbsp; &nbsp; Case 0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Label1.Caption = "Option 1 has the focus." &nbsp; &nbsp; &nbsp; Case 1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Label1.Caption = "Option 2 has the focus." &nbsp; &nbsp;End Select End Sub Private Sub OptionGroup_LostFocus (Index As Integer) &nbsp; &nbsp;Label1.Caption = "" End Sub </pre> <p><br /> </p> <p><br /> </p>