zoukankan      html  css  js  c++  java
  • 【VB.NET】类绑定控件,实现文本框快捷键全选

     1 Public Class KeyBinder
     2     Public Sub BindControl(ByRef CControl As TextBox)
     3         AddHandler CControl.KeyDown, AddressOf TextKeyDown
     4     End Sub
     5 
     6     Private Sub TextKeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
     7         MsgBox(sender)
     8         Dim txtControl As TextBox = CType(sender, TextBox)
     9         If e.KeyCode = Keys.A AndAlso (e.KeyData And Keys.Control) Then
    10             '全选
    11             txtControl.SelectAll()
    12         End If
    13         e.SuppressKeyPress = True
    14     End Sub
    15 End Class
    Public Class KeyBinder
        Public Sub BindControl(ByRef CControl As TextBox)
            AddHandler CControl.KeyDown, AddressOf TextKeyDown
        End Sub
    
        Private Sub TextKeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
            MsgBox(sender)
            Dim txtControl As TextBox = CType(sender, TextBox)
            If e.KeyCode = Keys.A AndAlso (e.KeyData And Keys.Control) Then
                '全选
                txtControl.SelectAll()
            End If
            e.SuppressKeyPress = True
        End Sub
    End Class
    

      

  • 相关阅读:
    环形二维数组
    梦断代码(三)
    梦断代码(二)
    梦断代码(一)
    CNblogs用户体验
    《软件工程》--读书笔记三
    《软件工程》--读书笔记二
    《软件工程》--读书笔记一
    找出水王
    典型用户
  • 原文地址:https://www.cnblogs.com/sunsoftresearch/p/4034060.html
Copyright © 2011-2022 走看看