VB.NET 2005: Textbox Cut Copy Paste with Keyboard

HardCode

Freshman
Joined
Apr 2, 2004
Messages
49
I can right-click in a TextBox control for the default ContextMenu with Cut, Copy, and Paste. However, I've noticed that in VB.NET 2005, you can't select text in a TextBox control and press CTRL+C, CTRL+X, or CTRL+V in them to cut, copy, or paste. I don't recall this behavior with VB.NET 2003, and definitely not with VB6 or Access VBA. Those TextBox controls always recognize the keyboard commands.

Is it that Microsoft's TextBox control doesn't realize these keypresses by default anymore? I tried setting the form's KeyPreview property to true to no avail. It seems kind of strange that you can no longer use the keyboard shortcuts for such basic functionality. Or, am I just missing something here?
 
Works fine for me... :confused:

Maybe you accidentially deslected everything just before you hit the hot key? Maybe the textbox is readonly so you can only copy, not cut or paste?
 
No ... I even tried again. CTRL+C won't copy the selected text to the Clipboard.

Some things about this form that may be preventing this:
1. The form is an ChildForm of an MDI Form
2. The TextBox control is within a Split control.
3. The TextBox control is set to Multiline.
4. No KeyPreview properties were changed.
5. The ChildForms are being set up as a single-instance only, via creating public properties on the MDI Parent, of type frm<MyForm>:
Visual Basic:
 Public Property NewQuestionForm() As frmNewQuestion
        Get
            If (fNewQuestion Is Nothing) OrElse (fNewQuestion.IsDisposed) Then
                fNewQuestion = New frmNewQuestion
                fNewQuestion.MdiParent = Me
            End If
            Return fNewQuestion
        End Get
        Set(ByVal Value As frmNewQuestion)
            fNewQuestion = Value
        End Set
    End Property

Let me start a new project and try it with the default form to see if it is only this project or not.

EDIT: Okay, so I started a new project and tried it. The keyboard shortcuts work fine. I tried with both the default TextBox, and I tried it with Multiline as true. Works fine. Hmmm, something about my specific project I think. I tried it on another MDI form in the problem project, and no keyboard copy-n-paste functionality either.
 
Last edited:
Are you doing any special key processing (Overriding OnKeyDown/Up/Press or handling KeyDown/UpPress, or anything local to the textbox or global to the app like intercepting messages or using any kinds of hooks, etc.)?
 
No, nothing at all. Just a default .NET controls on default forms assigned as Child Forms. Most odd ...
 
Did you ever resolve this issue? I am having the same one...
Thanks.

Hi,

I had the same issue with Visual Stusio 2008. For me it seems there is a bug in the form designer.
The solution was, to delete and recreate the TextBox control.

I also double checked the properties of the "corrupt" and "good" control. Both had the same. But some proteries were displayed bold for the corrupt control. I did not investigate deeper because it worked fine for me, if you like to do so, I would propose to go the same way.

  1. Create new
  2. TextBox control
  3. Set all properties like the corrupt one
  4. compare the properties view, and check/compare the code created automatically
by the designer.

Good luck and Regards,
Frank
 
Back
Top