Modifying contents of a textbox

Posted on 2006-05-18
Last Modified: 2010-04-23
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,

Question by:schealth
    LVL 34

    Accepted 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?


    Author Comment

    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


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Suggested Solutions

    Title # Comments Views Activity
    Deselect Grid view Row 4 28
    Check if excel is already open 4 31
    Converting string to currency 10 39 euclidean math 2 26
    This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
    I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now