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. Changing a form's title

Changing a form's title

Scheduled Pinned Locked Moved C#
question
5 Posts 4 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.
  • E Offline
    E Offline
    eggie5
    wrote on last edited by
    #1

    OK, so I have my main form 'Form1' and i'm in another class 'controls.cs'... How can I change the title of my main form 'Form1' from 'controls.cs'?? I tired...

      Form1 asdf=new Form1;
      asdf.text="RESPECT THE ENG";
    

    but that dosn't work. How can I do it? /\ |_ E X E GG

    J 1 Reply Last reply
    0
    • E eggie5

      OK, so I have my main form 'Form1' and i'm in another class 'controls.cs'... How can I change the title of my main form 'Form1' from 'controls.cs'?? I tired...

        Form1 asdf=new Form1;
        asdf.text="RESPECT THE ENG";
      

      but that dosn't work. How can I do it? /\ |_ E X E GG

      J Offline
      J Offline
      J Dunlap
      wrote on last edited by
      #2

      adf.Text, not asdf.text.

      "Blessed are the peacemakers, for they shall be called sons of God." - Jesus
      "You must be the change you wish to see in the world." - Mahatma Gandhi

      E 1 Reply Last reply
      0
      • J J Dunlap

        adf.Text, not asdf.text.

        "Blessed are the peacemakers, for they shall be called sons of God." - Jesus
        "You must be the change you wish to see in the world." - Mahatma Gandhi

        E Offline
        E Offline
        eggie5
        wrote on last edited by
        #3

        well, actually I have this on controls.cs... Form1 asdf = new Form1(); asdf.Text="RESPECT THE ENG"; now... the question i guess... on Form1, how do I call this? /\ |_ E X E GG

        R 1 Reply Last reply
        0
        • E eggie5

          well, actually I have this on controls.cs... Form1 asdf = new Form1(); asdf.Text="RESPECT THE ENG"; now... the question i guess... on Form1, how do I call this? /\ |_ E X E GG

          R Offline
          R Offline
          Rein Hillmann
          wrote on last edited by
          #4

          Form1 isn't an object. It's a class. asdf is an object (instance of a class). You need to change the text on asdf, not on Form1 and you can't do that unless you have a reference to asdf. You might need to enumerate all the forms until you find the one you want or you could pass a reference of the form to control.cs so that you can manipulate it later.

          F 1 Reply Last reply
          0
          • R Rein Hillmann

            Form1 isn't an object. It's a class. asdf is an object (instance of a class). You need to change the text on asdf, not on Form1 and you can't do that unless you have a reference to asdf. You might need to enumerate all the forms until you find the one you want or you could pass a reference of the form to control.cs so that you can manipulate it later.

            F Offline
            F Offline
            freshthinking
            wrote on last edited by
            #5

            try passing the form on the constructor of the control.cs object, and store this in the control object. i.e. private Form form1; public Control(Form form) { this.form1 = form; } You should then be able to make calls like form1.Text = "whatever". If that doesn't work quite try public Control(ref Form form).

            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