• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 312
  • Last Modified:

Modifying contents of a textbox

Hello, I've been searching a while for an answer to this question.  I have a textbox that is databound to data in a table.  When the user queries and returns data, the only way they can modify the contents of the textbox is to highlight the text within the textbox.  For example, I do a query and return "Data is valid".  I want to change the text to say "Data is not valid".  If i position my cursor after the is and start to type, nothing happens.  The only way for me to get the text inserted is to highlight from is on and then type the new text.  Is this normal?  The data isn't being inserted into the database yet so i'm not sure why this is doing this.  It happens if it's a richtextbox also.  Some of our data fields contain a lot of characters and my users are complaining about having to retype the entire contents of the textbox to just add a few characters.  I've checke the textbox length property and there is more than enough space to accomodate new text.

Thank you,

1 Solution
No, it's not normal - at least in the sense of not occurring with default settings in a test I've just done in a VB.NET 2003 app.  I don't think VB.NET 2005 is any different, but I haven't checked that.

Have you got any code in the text box's TextChanged event sub (for instance) which might be causing it?

Or the other thing I can think of is that the string in the textbox is longer than it looks because it is already right padded with spaces to the maximum length that the text box will allow.  When you "checked the textbox length property and there is more than enough space to accomodate new text" did you check the length of the string that was currently in TextBox.Text?  Or just the length of the string that you could actually see: that is, up to the end of the last non-space character?

schealthAuthor Commented:
Thank you!  I'm banging my head against the wall because I never thought to check to see if it was padding spaces after the text (which is was).

Thanks for the quick response


Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now