[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
Re: Show remaining characters in Text Box
You can write this code in the change event of the TextBox.
VB Code:
Debug.WriteLine ((textBox1.MaxLength - textBox1.Text.Length).ToString());
This is just an example.
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
[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
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.