Hello ALL:

In my form there is a textbox and label ,I want when I input a text when I'm inputting the first letter in the label value must be 1 if I input 2 letters in the label value it must be 2 ...etc...
Any idea????

Hello :

In textBox I must enter texts, this text it's contains of many letters, when I enter the first letter , (label) value(text) must be 1, when I enter 2 letters (label) text must be 2 and so on ???

do you mean
1.that if i type in "hello" in textbox, your label should reflect what has been typed (therefore the label text will be "hello")?
2.or do you mean that if I type in "hello"in to the textbox you want the label text set to "5" (because of five letters in "hello")?

Hello :

Thanks a lot for your explain , actually yes I thinked of enter words ie(hello), and in the label text must be 5, but each letter when it's enter the label take values untill reach 5, for example when you enter h
the label must be 1 , and if you enter e(besides of h) the lable must be 2 and so on>>>>Thanks in advance<<<<<

if a user types "hello" then presses backspace to remove the "o" what would you like to happen then ? the label to read 4 ?

ok you need to write some code in the textbox text changed event. (double click the textbox to make event hander) are you using Visual studio ?

Hello :

thanks a lot for your support , yes it must take 4....

ok, well so far I have this:

ctr++;
            label1.Text= textBox1.Text;
            label2.Text = ctr.ToString();

This, however, doesnt reduce the label to 4 if a character is deleted. But im going to look at that now.

what you need to do to get the label to say 4 or whatever is reduce the counter with this statement

ctr--

this needs to go in an event handler that is capable of detecting if the backspace is pressed. you see, a backspace is recognised as a character. hope this helps.

Hello :
can you please re-write the final answer?? and what label2 for??
thanks in advance///

public partial class Form1 : Form
    {
        int ctr = 0;
        public Form1()
        {
            InitializeComponent();
        }

        private void textBox1_TextChanged(object sender,EventArgs e)
        {                                 
                ctr++;
                label1.Text = ctr.ToString();            
        }

        
    }

nice one! was not aware of that !

No, in text change event handler for the textbox let the label2.Text = textBox.Text.Length.ToString();

This question has already been answered. Start a new discussion instead.