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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Windows Forms Question

Windows Forms Question

Scheduled Pinned Locked Moved C#
questionwinforms
6 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.
  • 1 Offline
    1 Offline
    1nsp1r3d
    wrote on last edited by
    #1

    Hi all, I've started coding a windows form without the designer and suddenly I needed to set one of this property. Then I took a look at the code and saw that the designer added a function InitializeComponent() and did the setting of the property there. Couldn't the property be set in the Form's constructor? And where can I find some docs on InitializeComponent() cause I looked at MSDN and couldn't find any. Any advice is greatly appreciated. Regards

    L H 2 Replies Last reply
    0
    • 1 1nsp1r3d

      Hi all, I've started coding a windows form without the designer and suddenly I needed to set one of this property. Then I took a look at the code and saw that the designer added a function InitializeComponent() and did the setting of the property there. Couldn't the property be set in the Form's constructor? And where can I find some docs on InitializeComponent() cause I looked at MSDN and couldn't find any. Any advice is greatly appreciated. Regards

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Of course you can set the properties in the constructor. I bet the VS designer just creates an "InitializeComponents" method so it can better keep track of the changes made directly through the designer. That's why the designer can get confused if you modify the "InitializeComponents" section too much. regards

      1 1 Reply Last reply
      0
      • L Lost User

        Of course you can set the properties in the constructor. I bet the VS designer just creates an "InitializeComponents" method so it can better keep track of the changes made directly through the designer. That's why the designer can get confused if you modify the "InitializeComponents" section too much. regards

        1 Offline
        1 Offline
        1nsp1r3d
        wrote on last edited by
        #3

        But is this function automatically called? Because I cannot see any point where it is called.

        L 1 Reply Last reply
        0
        • 1 1nsp1r3d

          But is this function automatically called? Because I cannot see any point where it is called.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Take a closer look at the Form() constructor ;)

          1 Reply Last reply
          0
          • 1 1nsp1r3d

            Hi all, I've started coding a windows form without the designer and suddenly I needed to set one of this property. Then I took a look at the code and saw that the designer added a function InitializeComponent() and did the setting of the property there. Couldn't the property be set in the Form's constructor? And where can I find some docs on InitializeComponent() cause I looked at MSDN and couldn't find any. Any advice is greatly appreciated. Regards

            H Offline
            H Offline
            heavenamour
            wrote on last edited by
            #5

            Hello Dear... InitializeComponent() Is not a special thing ! This is a common function. It will call in Constructor.You can move all codes in this function to the constructor directely ! But You can't change this codes in designer ! Designer (VS.NET) Protects this portion of codes.If you change some codes in this area,Designer will reproduce theme at each rebuild. I hope this was helpful for you, Bye

            A 1 Reply Last reply
            0
            • H heavenamour

              Hello Dear... InitializeComponent() Is not a special thing ! This is a common function. It will call in Constructor.You can move all codes in this function to the constructor directely ! But You can't change this codes in designer ! Designer (VS.NET) Protects this portion of codes.If you change some codes in this area,Designer will reproduce theme at each rebuild. I hope this was helpful for you, Bye

              A Offline
              A Offline
              Anonymous
              wrote on last edited by
              #6

              Thanks a lot:cool:

              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