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. control in another form

control in another form

Scheduled Pinned Locked Moved C#
question
6 Posts 5 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.
  • M Offline
    M Offline
    m m _2007
    wrote on last edited by
    #1

    how can i access control (like button) in one form(form 1) from another from(form 2).. i want to set the enabled property of this control rom form 2

    E M Q 3 Replies Last reply
    0
    • M m m _2007

      how can i access control (like button) in one form(form 1) from another from(form 2).. i want to set the enabled property of this control rom form 2

      E Offline
      E Offline
      e laj
      wrote on last edited by
      #2

      Set the "Modifiers" property of this control to public (or set the button access level to public by your self). After that you will be able to see that control in the intelisense from another form. Enjoy

      M 1 Reply Last reply
      0
      • E e laj

        Set the "Modifiers" property of this control to public (or set the button access level to public by your self). After that you will be able to see that control in the intelisense from another form. Enjoy

        M Offline
        M Offline
        m m _2007
        wrote on last edited by
        #3

        thx but still cant access enabled property

        A 1 Reply Last reply
        0
        • M m m _2007

          thx but still cant access enabled property

          A Offline
          A Offline
          Anthony Mushrow
          wrote on last edited by
          #4

          Errm do: public static System.Windows.Forms.Button YourButton; then change all 'this.YourButton' to just 'YourButton' (without the 'this.') Then you can just access the button from anywhere, works for me, well i've never done it for a button but, im sure it'll be fine.

          1 Reply Last reply
          0
          • M m m _2007

            how can i access control (like button) in one form(form 1) from another from(form 2).. i want to set the enabled property of this control rom form 2

            M Offline
            M Offline
            mnvkng76
            wrote on last edited by
            #5

            m.m._2007 wrote:

            how can i access control (like button) in one form(form 1) from another from(form 2).. i want to set the enabled property of this control rom form 2

            If you have a webForm1 page with one button on it you could do this webForm1 sf = new webForm1(); sf.Controls["button"].enabled=false; sf.Show(); When the form opens the button would be disabled. Of course you need to know the controls name, or index. I hope this was usefull:)

            1 Reply Last reply
            0
            • M m m _2007

              how can i access control (like button) in one form(form 1) from another from(form 2).. i want to set the enabled property of this control rom form 2

              Q Offline
              Q Offline
              quiteSmart
              wrote on last edited by
              #6

              HI, You can just create a function in the first form and declare it as public. In the body of this function you can right the property changes of the button that u wish. And just call this function from the second form. This will do i think, Jamil Abou Khalil

              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