Sean
Sean

Reputation: 133

Textbox contents are overwritten, not appended to, on paste

I've got a VB.Net application I inherited that has an annoying issue with the textboxes.

They don't seem to behave in a 'standard' manner. For example, pressing 'Ctrl+A' with the cursor in them doesn't select all. Mouse wheel won't scroll the box.

But the main issue that I want to get fixed is the paste problem. When I have text on the clipboard, and I paste, the contentc of the box are not appended to. Instead they are overwritten.

It's not a case of accidentally having all of the contents selected when I paste. Even when I'm very careful to have nothing selected, the contents are overwritten.

This happens with all textboxes in this application. So far I've browsed through the properties of one of the TextBoxes to see if anything looked related - nothing did. I searched the code to see if a property was set somewhere to account for this - nothing was. And I Googled and checked here but couldn't find a simmilar issue.

I don't work in VB often so I might be missing something obvious - but I can't find the answer anywhere.

And just to see what would happen I just added a new TextBox. It had the same behavior despite my putting it in and not modifying any of it's properties or writing any code related to it.

Being able to append text to what is present in these textboxes would be really helpful for the people who use this program.

Thanks for taking the time to read my question, and for any help you can provide!

I don't know what aditional info might be helpful, so if you need anything let me know.

Upvotes: 1

Views: 340

Answers (2)

rheitzman
rheitzman

Reputation: 2297

It appears that the TextBox supports the standard clipboard keys in the standard way (insert at cursor, replace selection) but not Ctrl-A.

The RichTextBox does support Ctrl-A so that might be a quick fix.

Otherwise use Textbox.KeyDown event to handled Ctrl-A

    If e.Control And e.KeyCode = Keys.A Then
        TextBox1.SelectAll()
        e.Handled = True
    End If

Upvotes: 0

Hichem
Hichem

Reputation: 1182

texbox1.text = "Myoldvalue" 

textbox1.text & = " Add this too" 

msgbox(textbox1.text) 


OutPut : 

Myoldvalue Add this too

Upvotes: 1

Related Questions