FIX: CTRL+C Does Not Copy From a Locked TextBoxID: Q216175
|
If a textbox on a form has its Locked property set to True, and the CTRL+C shortcut is used to copy text in the textbox, the selected text will not be copied to the clipboard.
To work around this behavior, you must use the textbox's KeyDown event to check for a CTRL+C key combination. If CTRL+C does occur, then you must programatically put the selected text on the clipboard, as follows:
If KeyCode = 67 And Shift = vbCtrlMask Then
Clipboard.Clear
Clipboard.SetText Text1.SelText
End If
See the MORE INFORMATION section below for an example of the workaround.
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article.
This bug was corrected in Visual Studio 6.0 Service Pack 3.
For more information about Visual Studio 6.0 Service Packs, please see the following articles in the Microsoft Knowledge Base:
Q194022 INFO: Visual Studio 6.0 Service Packs, What, Where, Why
Q194295 HOWTO: Tell That Visual Studio 6.0 Service Packs Are Installed
Private Sub Form_Load()
Text1.Locked = True
Text1.Text = "This is a test."
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 67 And Shift = vbCtrlMask Then
Clipboard.Clear
Clipboard.SetText Text1.SelText
End If
End Sub
Online Help for Microsoft Visual Basic, version 6.0
Additional query words: keyboard
Keywords : kbservicepack kbClipboard kbVBp kbVBp600bug kbVS600sp3fix
Version : WINDOWS:6.0
Platform : WINDOWS
Issue type : kbbug
Last Reviewed: May 19, 1999