1 怎么让一个txt得到焦点后且是**选中**状态(反白显法)
 2     
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    
If KeyCode = vbKeyReturn Then SendKeys "{Tab}"End Subkeypreview 也设为true了,但为什么焦点不变换呢?有时好用有时不好用?

解决方案 »

  1.   

    Option ExplicitPrivate Sub Text1_GotFocus()
        SendKeys "{home}+{end}"
    End Sub
      

  2.   

    SendKeys "{home}+{end}"
    我也给放到Form_KeyDown事件下了。也没好用。不知为什么了
      

  3.   

    2. 不是写在窗体的keydown事件,而是写在窗体上的各个控件的keydown事件。
      

  4.   

    SendKeys "{home}+{end}"同理也是写在控件的gotfocus事件。
      

  5.   

    text有很多啊。每一个都得写?这个在Form_KeyDown理论上应是可以的啊。但不知我的是怎么了?
    反白显示记得用:SelStart属性和SelLength可以实现。忘了
      

  6.   

    1、
    Private Sub Text1_GotFocus()
        Text1.SelStart = 0
        Text1.SelLength = Len(Text1.Text)
    End Sub
    2、
    Private Sub Form_KeyPress(KeyAscii As Integer)
        If KeyAscii = vbKeyReturn Then SendKeys "{Tab}"
    End Sub
      

  7.   

    text1.selstart=0/1? '忘了
    text1.sellength=len(text1.text)
      

  8.   

    Private Sub Form_KeyPress(KeyAscii As Integer)
        If KeyAscii = vbKeyReturn Then SendKeys "{Tab}"
    End Sub
    这个也不好用啊。