[c#]Displays current character/character limit

03/10/2011 10:31 zhalyn#1
I have searched on google and youtube but still i can't understand how
to show the current character on the label :S

PHP Code:
        private void CharLimit()
        {
           if (
textBox1.Text.Length >= 160)
               for (
int i 160Text.Lengthi--)
               {
                   
label1.Text Text.Length.ToString();
               }

        }




        private 
void label1_Click(object senderEventArgs e)
        {
            
CharLimit();
            
        }

        private 
void textBox1_TextChanged(object senderEventArgs e)
        {
            
CharLimit();
        } 
03/10/2011 13:06 Korvacs#2
Code:
label1.Text = Text.Length.ToString(); 
label1.Refresh();
A simple look through the methods associated to the label could have solved this issue.
03/11/2011 10:54 zhalyn#3
Quote:
Originally Posted by Korvacs View Post
Code:
label1.Text = Text.Length.ToString(); 
label1.Refresh();
A simple look through the methods associated to the label could have solved this issue.
Nice, but still the label1's text are not showing the right character counts :S

PHP Code:
 public void CharLimit()
        {
            if (
textBox1.Text.Length >= 160)
                for (
int i 160>= 160i--)
            {
                
label3.Text Text.Length.ToString();
                
label3.Refresh();
            }
        }

        private 
void label3_Click(object senderEventArgs e)
        {
            
CharLimit();
        }

        private 
void textBox1_TextChanged(object senderEventArgs e)
        {
            
CharLimit();
        } 
where if i type, character count counts down from 160 to 0 :S
03/11/2011 11:40 Korvacs#4
Yeah because you have written it so that your loop starts at 160, and then counts down.

You dont know what you've written?

What do you want to do?
03/11/2011 11:52 zhalyn#5
Quote:
Originally Posted by Korvacs View Post
Yeah because you have written it so that your loop starts at 160, and then counts down.

You dont know what you've written?

What do you want to do?
Never mind i found it
PHP Code:
  private void textBox1_TextChanged(object senderEventArgs e)
        {
            
this.label3.Text Convert.ToString(this.textBox1.TextLength) + " Characters Long";
            if (
textBox1.Text.Length >= 160)
            {
                
button1.Enabled false;
                
MessageBox.Show("Character Limit Reached to 160");
            }   
            else
            {
                
button1.Enabled true;
            } 
but it will display characters length :S any tip to make it a countdown?
em going to write a SMS bomber
03/11/2011 12:02 Korvacs#6
You really need to learn to use google, read some basic C# Tutorials, and understand how to perform basic methods and how these can be utilised in order to perform many tasks with a small amount of modifications.

I dont really want to help write an 'SMS Bomber' to be honest, and from the looks of it, I would end up helping alot.
03/11/2011 12:17 zhalyn#7
Quote:
Originally Posted by Korvacs View Post
You really need to learn to use google, read some basic C# Tutorials, and understand how to perform basic methods and how these can be utilised in order to perform many tasks with a small amount of modifications.

I dont really want to help write an 'SMS Bomber' to be honest, and from the looks of it, I would end up helping alot.
Well I'm just asking for some minor problems regarding on c# syntaxes :)
thank you!
03/11/2011 14:10 nTL3fTy#8
Quote:
Originally Posted by zhalyn View Post
any tip to make it a countdown?
limit - current?
03/11/2011 14:23 zhalyn#9
Quote:
Originally Posted by nTL3fTy View Post
limit - current?
Ops, What i mean is i want to set count from 160 to 0 but
PHP Code:
 this.label3.Text Convert.ToString(this.textBox1.TextLength) + " Characters Long"
it shows the count from 0 to 160 :S
03/11/2011 14:36 nTL3fTy#10
Quote:
Originally Posted by zhalyn View Post
PHP Code:
 this.label3.Text Convert.ToString(this.textBox1.TextLength) + " Characters Long"
PHP Code:
 this.label3.Text = (160 textBox1.TextLength) + " Characters Left"
03/11/2011 16:01 zhalyn#11
Quote:
Originally Posted by nTL3fTy View Post
PHP Code:
 this.label3.Text = (160 textBox1.TextLength) + " Characters Left"
thanks :)

Now i have one more problem regarding the form size :S

PHP Code:
 private void checkBox1_CheckedChanged(object senderEventArgs e)
        {
            if (
checkBox1.Checked == true)
            {
                
timer2.Start();
            } 
PHP Code:
      private void timer2_Tick(object senderEventArgs e)
        {
            if (
Width >= 389)
            {
                
timer2.Stop();
            }
            else
            {
                
Width += 288;
            }
            if (
checkBox1.Checked == false)
            {
                
timer2.Start();
                if (
Width >= 677)
                {
                    
Width -= 288;
                }
            }

        } 
my width wont resize to 389 size :S
im so confuse where i did something wrong