Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to assign the text to toolstripstatus in runtime?

How to assign the text to toolstripstatus in runtime?

Scheduled Pinned Locked Moved C#
csharphelptutorialquestion
8 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    savitri
    wrote on last edited by
    #1

    Hello All, I am Savitri Here. I am new to this forum and also to this language. I am doing one application in C#. Now i have two forms called Mainform and LoginForm. After running we login form will come and after successful login will get mainform. I want to assign the entered user name to toolstripstautuslable of statusstrip which is in mainform.When i clicking login button then only i am setting new value for that status strip but it is not assigning. Please help me. Below is the part of code. LoginForm.Cs MainForm frm = new MainForm(); private void btnLogin_Click(object sender, EventArgs e) { string username,password; username=txtUsr.Text.ToString(); password=txtPwd.Text.ToString(); if(username.Equals("xxxxxx") && password.Equals("xxxxxx")) { MessageBox.Show("SuccessFully Logged in"); frm.toolStripStatusLabel2.Text = txtUsr.Text; frm.GetValues(username, password);//textBox1_TextChanged(); this.Visible=false; } else { MessageBox.Show("Not valid UserName and Password"); } } MainForm.cs public void GetValues(string strUsr,string strPwd) { this.UsrNam=strUsr; MessageBox.Show(UsrNam); this.PasPwd=strPwd; MessageBox.Show(PasPwd); this.toolStripStatusLabel2.Text = UsrNam.ToString(); this.Refresh(); } Please Give me hints. Help me. Thanks in Advance. Regards, Savitri P

    H 1 Reply Last reply
    0
    • S savitri

      Hello All, I am Savitri Here. I am new to this forum and also to this language. I am doing one application in C#. Now i have two forms called Mainform and LoginForm. After running we login form will come and after successful login will get mainform. I want to assign the entered user name to toolstripstautuslable of statusstrip which is in mainform.When i clicking login button then only i am setting new value for that status strip but it is not assigning. Please help me. Below is the part of code. LoginForm.Cs MainForm frm = new MainForm(); private void btnLogin_Click(object sender, EventArgs e) { string username,password; username=txtUsr.Text.ToString(); password=txtPwd.Text.ToString(); if(username.Equals("xxxxxx") && password.Equals("xxxxxx")) { MessageBox.Show("SuccessFully Logged in"); frm.toolStripStatusLabel2.Text = txtUsr.Text; frm.GetValues(username, password);//textBox1_TextChanged(); this.Visible=false; } else { MessageBox.Show("Not valid UserName and Password"); } } MainForm.cs public void GetValues(string strUsr,string strPwd) { this.UsrNam=strUsr; MessageBox.Show(UsrNam); this.PasPwd=strPwd; MessageBox.Show(PasPwd); this.toolStripStatusLabel2.Text = UsrNam.ToString(); this.Refresh(); } Please Give me hints. Help me. Thanks in Advance. Regards, Savitri P

      H Offline
      H Offline
      Henry Minute
      wrote on last edited by
      #2

      Does this line MessageBox.Show(UsrNam); show the username?

      Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

      S 1 Reply Last reply
      0
      • H Henry Minute

        Does this line MessageBox.Show(UsrNam); show the username?

        Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

        S Offline
        S Offline
        savitri
        wrote on last edited by
        #3

        Hi Henry, Ya that is user name. I want to display that user name into status strip in main from. Please give me some hints to solve this problem. Thanks in Advance. Regards, Savitri P

        H 1 Reply Last reply
        0
        • S savitri

          Hi Henry, Ya that is user name. I want to display that user name into status strip in main from. Please give me some hints to solve this problem. Thanks in Advance. Regards, Savitri P

          H Offline
          H Offline
          Henry Minute
          wrote on last edited by
          #4

          Yes, I understand that, but when the MessageBox displays, does it show the username, is it blank, does it display something that you are not expecting?

          Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

          S 1 Reply Last reply
          0
          • H Henry Minute

            Yes, I understand that, but when the MessageBox displays, does it show the username, is it blank, does it display something that you are not expecting?

            Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

            S Offline
            S Offline
            savitri
            wrote on last edited by
            #5

            Ya it is displaying username in messagebox but it is not showing in status strip and not refreshing control also. I tried many ways but it is not displaying. Regards, Savitri P

            H 1 Reply Last reply
            0
            • S savitri

              Ya it is displaying username in messagebox but it is not showing in status strip and not refreshing control also. I tried many ways but it is not displaying. Regards, Savitri P

              H Offline
              H Offline
              Henry Minute
              wrote on last edited by
              #6

              The code you have provided, is over complicated: your code:

              public void GetValues(string strUsr,string strPwd)
              {
              this.UsrNam=strUsr;
              MessageBox.Show(UsrNam);
              this.PasPwd=strPwd;
              MessageBox.Show(PasPwd);
              this.toolStripStatusLabel2.Text = UsrNam.ToString();
              this.Refresh();
              }

              can be simplified to:

              public void GetValues(string strUsr,string strPwd)
              {
              this.UsrNam=strUsr;
              MessageBox.Show(UsrNam);
              this.PasPwd=strPwd;
              MessageBox.Show(PasPwd);
              this.toolStripStatusLabel2.Text = UsrNam;
              }

              other than that I can see no obvious reason that it should not work. As a test that toolStripStatusLabel2 is working, temporarily replace this.toolStripStatusLabel2.Text = UsrNam; with this.toolStripStatusLabel2.Text = "Is this visible";. If you can see "Is this visible" when you run the application, then I am at a loss. If however, you cannot see it, then there is something wrong with one of the properties of toolStripStatusLabel2 possibly the Visible property is set to false, possibly the location or size properties are incorrectly set. It might even be hidden behind another control.

              Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

              S 1 Reply Last reply
              0
              • H Henry Minute

                The code you have provided, is over complicated: your code:

                public void GetValues(string strUsr,string strPwd)
                {
                this.UsrNam=strUsr;
                MessageBox.Show(UsrNam);
                this.PasPwd=strPwd;
                MessageBox.Show(PasPwd);
                this.toolStripStatusLabel2.Text = UsrNam.ToString();
                this.Refresh();
                }

                can be simplified to:

                public void GetValues(string strUsr,string strPwd)
                {
                this.UsrNam=strUsr;
                MessageBox.Show(UsrNam);
                this.PasPwd=strPwd;
                MessageBox.Show(PasPwd);
                this.toolStripStatusLabel2.Text = UsrNam;
                }

                other than that I can see no obvious reason that it should not work. As a test that toolStripStatusLabel2 is working, temporarily replace this.toolStripStatusLabel2.Text = UsrNam; with this.toolStripStatusLabel2.Text = "Is this visible";. If you can see "Is this visible" when you run the application, then I am at a loss. If however, you cannot see it, then there is something wrong with one of the properties of toolStripStatusLabel2 possibly the Visible property is set to false, possibly the location or size properties are incorrectly set. It might even be hidden behind another control.

                Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

                S Offline
                S Offline
                savitri
                wrote on last edited by
                #7

                Hi Henry, Thanks a lot.I got the result correctly. Thanku very much. Regards, Savitri P

                H 1 Reply Last reply
                0
                • S savitri

                  Hi Henry, Thanks a lot.I got the result correctly. Thanku very much. Regards, Savitri P

                  H Offline
                  H Offline
                  Henry Minute
                  wrote on last edited by
                  #8

                  My pleasure. Good Luck. :)

                  Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups