就是本来一个按钮要鼠标点击才能执行,现在想换成按回车去代替鼠标点击,请高手指教,这应该怎么实现啊?

解决方案 »

  1.   

    如果窗體上有多個控件的話,要先保證按鈕得到焦點
    command1_keydown()
    if keycode=13 then
       command1.value=true
    endif
      

  2.   

    Form.KeyPreview=true
    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
      if Keycode=13 then
        '调用那个按钮的  OnClick() 事件
      end if
    End Sub  
      

  3.   

    把按钮的Default属性设置为True
      

  4.   

    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
      if Keycode=13 then
          command1_click
      end if
    End Sub