[vb.net] TextBox Ctrl+c and Ctrl+v how to implement > vb.net

본문 바로가기

vb.net

[Controls] [vb.net] TextBox Ctrl+c and Ctrl+v how to implement

회원사진
하나를하더라도최선을
2021-03-18 20:29 4,647 0

본문



    Private Function SET_TEXT_BOX_CLIPBOARD_SHORTCUTS(ByRef f As Form) As Boolean
        Dim C As Control = f
        Do
            C = f.GetNextControl(C, True)
            Try
                Select Case True
                    Case C Is Nothing
                    Case TypeOf C Is TextBox
                        AddHandler CType(C, TextBox).KeyUp, AddressOf TextBox_KeyUp
                End Select
            Catch ex As Exception
                el.WriteToErrorLog(ex.Message, ex.StackTrace, "Error")
            End Try
        Loop Until C Is Nothing
    End Function
 
    Private Sub TextBox_KeyUp(sender As Object, e As KeyEventArgs)
        Dim t As TextBox = CType(sender, TextBox)
        If e.KeyData = (Keys.C Or Keys.Control) Then
            t.Copy()
            e.Handled = True
        ElseIf e.KeyData = (Keys.X Or Keys.Control) Then
            t.Cut()
            e.Handled = True
        ElseIf e.KeyData = (Keys.V Or Keys.Control) Then
            t.Paste()
            e.Handled = True
        ElseIf e.KeyData = (Keys.A Or Keys.Control) Then
            t.SelectAll()
            e.Handled = True
        ElseIf e.KeyData = (Keys.Z Or Keys.Control) Then
            t.Undo()
            e.Handled = True
        End If
    End Sub

댓글목록0

등록된 댓글이 없습니다.
게시판 전체검색