|
-
Jun 23rd, 2006, 06:49 AM
#1
Thread Starter
Hyperactive Member
[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)
-
Jun 23rd, 2006, 07:04 AM
#2
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.
Use [code] source code here[/code] tags when you post source code.
My Articles
-
Jun 23rd, 2006, 09:09 AM
#3
Thread Starter
Hyperactive Member
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
-
Jun 23rd, 2006, 09:26 AM
#4
Thread Starter
Hyperactive Member
[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
-
Jun 24th, 2006, 05:25 AM
#5
Re: Show remaining characters in Text Box
 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|