Problem with appearing text in textboxt after progressbar load

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ohay
    New Member
    • Jun 2013
    • 6

    #1

    Problem with appearing text in textboxt after progressbar load

    I'm kinda in trouble because wanna do appearing text in textbox after load 100 % in progressbar but I don't knowwhy the text is appearing after I click the button which starting progressbar. I wanna make the text appearing after progressbar load. Here's the code...
    Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    
    namespace WindowsFormsApplication1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
    
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                textBox1.Text = "5646359412";
                MessageBox.Show("Wait until progressbar ends", "Message");
                this.timer1.Start();
    
            }
    
            private void timer1_Tick(object sender, EventArgs e)
            {
                progressBar1.Minimum = 0;
                progressBar1.Maximum = 100;
                progressBar1.Step = 3;
                progressBar1.PerformStep();
            }
    
            private void radioButton4_CheckedChanged(object sender, EventArgs e)
            {
    
            }
    
            private void radioButton1_CheckedChanged(object sender, EventArgs e)
            {
    
    
            }
    
            private void textBox1_TextChanged(object sender, EventArgs e)
            {
    
    
    
                if (progressBar1.Maximum == 100)
                    
                {
                    textBox1.Text = "5646359412";
    
                    
                    
                   
                }
    
                    
    
                
    
    
    
    
    
    
    
            }
    
            private void progressBar1_Click(object sender, EventArgs e)
            {
    
            }
        }
    }
    Last edited by Frinavale; Jun 17 '13, 09:02 PM. Reason: Please use code tags when posting code.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    You mean the text in textbox1? You show it on line 26 before you start your timer.

    Comment

    • Ohay
      New Member
      • Jun 2013
      • 6

      #3
      Still dont get it, tried much ways and dont working. If you can edit it...
      Code:
      using System;
      using System.Collections.Generic;
      using System.ComponentModel;
      using System.Data;
      using System.Drawing;
      using System.Linq;
      using System.Text;
      using System.Windows.Forms;
      
      namespace WindowsFormsApplication1
      {
          public partial class Form1 : Form
          {
              public Form1()
              {
                  InitializeComponent();
              }
      
              private void Form1_Load(object sender, EventArgs e)
              {
      
              }
      
              private void button1_Click(object sender, EventArgs e)
              {
                  
                  MessageBox.Show("Wait until progressbar ends", "Message");
                  this.timer1.Start();
                  
      
              }
      
              private void timer1_Tick(object sender, EventArgs e)
              {
                  progressBar1.Minimum = 0;
                  progressBar1.Maximum = 100;
                  progressBar1.Step = 3;
                  progressBar1.PerformStep();
              }
      
              private void radioButton4_CheckedChanged(object sender, EventArgs e)
              {
      
              }
      
              private void radioButton1_CheckedChanged(object sender, EventArgs e)
              {
      
      
              }
      
              private void textBox1_TextChanged(object sender, EventArgs e)
              {
      
      
      
                  if (progressBar1.Value == 100)
                      
                  {
                      
                      textBox1.Text = "5646359412";
                      this.timer1.Stop();
                      
      
                      
                      
                     
                  }
      
                      
      
                  
      
      
      
      
      
      
      
              }
      
              private void progressBar1_Click(object sender, EventArgs e)
              {
      
              }
          }
      }

      Comment

      • M1kkelZU
        New Member
        • Feb 2013
        • 80

        #4
        I'd guess what rabbit is saying is that you alread declared the text in the textbox on Line 26 (first post) as "5646359412 " before the timer even started so the text is always going to be "5646359412 " even when the timer and progressbar finishes.

        Comment

        • Ohay
          New Member
          • Jun 2013
          • 6

          #5
          So look to my 2nd post, i declared the textBox1.Text = "5646359412 "; before the timer stopped (61 line), and when the progressbar ends up, the textbox is still empty, u can try this code in visual and edit it if it dont work for you, thanks.

          Comment

          • Frinavale
            Recognized Expert Expert
            • Oct 2006
            • 9749

            #6
            If this is a WinForms application, have you considered calling UpdateLayout on the TextBox before you start the timer?

            You need to tell the UI to update/refresh and then start your timer.

            -Frinny

            Comment

            • Ohay
              New Member
              • Jun 2013
              • 6

              #7
              I dont have problem with that, i have problem with code which saying what to do when the progressbar ends. The progressbar is loading to 100 % and then i wanna show some message in textbox, but dont know how to write that because
              Code:
              if progressBar1.value = 100
              not working...

              Comment

              • Rabbit
                Recognized Expert MVP
                • Jan 2007
                • 12517

                #8
                Why are you checking for the value in textBox1_TextCh anged?

                Comment

                • Ohay
                  New Member
                  • Jun 2013
                  • 6

                  #9
                  I don't know, so where should I put it to make it work well?
                  Last edited by Frinavale; Jun 17 '13, 09:02 PM.

                  Comment

                  • Rabbit
                    Recognized Expert MVP
                    • Jan 2007
                    • 12517

                    #10
                    That depends on when you want it to do the check. If it were me, I would want it to check right after the bar progresses so I would put it in the timer tick event.

                    Comment

                    Working...