Results 1 to 5 of 5

Thread: [RESOLVED] Show remaining characters in Text Box

  1. #1

    Thread Starter
    Hyperactive Member Pozzi's Avatar
    Join Date
    Feb 2001
    Location
    The Stones!
    Posts
    507

    Question [RESOLVED] Show remaining characters in Text Box

    Hi,

    I need to limit the number of characters available in a text box, which is straight forward.

    The thing is I'd like to show in a status bar the number of characters left as the user types into the text box.

    Can anyone give me any advice on the best approach, or know of any examples of this?

    Thanks & Regards
    Last edited by Pozzi; Jun 23rd, 2006 at 09:27 AM. Reason: Resolved
    VB.Net (VS 2010)

  2. #2
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Show remaining characters in Text Box

    You can write this code in the change event of the TextBox.
    VB Code:
    1. Debug.WriteLine ((textBox1.MaxLength - textBox1.Text.Length).ToString());
    This is just an example.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  3. #3

    Thread Starter
    Hyperactive Member Pozzi's Avatar
    Join Date
    Feb 2001
    Location
    The Stones!
    Posts
    507

    Re: Show remaining characters in Text Box

    Hi,

    Thanks for the reply, but the example you've provided is for VB or not?

    I'm looking for a C# example.

    Regards
    VB.Net (VS 2010)

  4. #4

    Thread Starter
    Hyperactive Member Pozzi's Avatar
    Join Date
    Feb 2001
    Location
    The Stones!
    Posts
    507

    [REOLVED] Show remaining characters in Text Box

    RESOLVED

    Found the solution I was looking for...

    Code:
    		private void txtMessage_TextChanged_1(object sender, System.EventArgs e)
    		{
    			int i = 160 - txtMessage.Text.Length;
    			label7.Text = i.ToString();
    		
    		}
    Regards
    VB.Net (VS 2010)

  5. #5
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Show remaining characters in Text Box

    Quote Originally Posted by Pozzi
    Hi,

    Thanks for the reply, but the example you've provided is for VB or not?

    I'm looking for a C# example.

    Regards
    That code was C# code. Look at the semi-colon at the end of the line.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width