Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine number of characters entered into textbox with C#

Hi I was wanting to display the number of characters entered into a textbox and I want it to update as I type how can I go about this?

Here is what I have:

int kk = textBox1.MaxLength;
int jj = //This is what I need to know.
string lol = jj.ToString() + "/" + kk.ToString();
label2.Text = lol;
like image 701
John_Dong Avatar asked Nov 17 '25 20:11

John_Dong


2 Answers

How about

int jj = textBox1.Text.Length;

Or am I missing something?

like image 185
Jon Skeet Avatar answered Nov 19 '25 09:11

Jon Skeet


The text of the text box will be a string, so it has a Length property, i.e.:

textBox1.Text.Length
like image 38
Stuart Golodetz Avatar answered Nov 19 '25 09:11

Stuart Golodetz