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. Windows Forms
  4. Placing Code - InitializeComponent Function()

Placing Code - InitializeComponent Function()

Scheduled Pinned Locked Moved Windows Forms
questionc++winformshelp
3 Posts 3 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.
  • P Offline
    P Offline
    pix_programmer
    wrote on last edited by
    #1

    Hi! I'm using Windows Forms C++. I've placed my code(like adding event handler and some IO&String handling) inside the void InitializeComponent(void) function. It's stated that not to modify this function with any code editor. Will this result in any problem in the future? If so, Where should I place my own code? Excuse me,if it is a silly Question. I've not used Windows Forms before. Can any body suggest any online material for Windows Forms as a start up?

    G L 2 Replies Last reply
    0
    • P pix_programmer

      Hi! I'm using Windows Forms C++. I've placed my code(like adding event handler and some IO&String handling) inside the void InitializeComponent(void) function. It's stated that not to modify this function with any code editor. Will this result in any problem in the future? If so, Where should I place my own code? Excuse me,if it is a silly Question. I've not used Windows Forms before. Can any body suggest any online material for Windows Forms as a start up?

      G Offline
      G Offline
      Ger Hayden
      wrote on last edited by
      #2

      No. I recommend placing it after the call to InitailzeComponent e.g.:

      		InitializeComponent();
      		//
      		//TODO: Add the constructor code here
      		//
      		m\_CellInError = gcnew Point(-2, -2); // Needed for Error Icon on grid
      

      You can also use Visual Studio's IDE to add a FormLoad Event for set up stuff. Code in the InitializeComponent that you add yourself risks being erased when the IDE refreshes your form

      Ger

      1 Reply Last reply
      0
      • P pix_programmer

        Hi! I'm using Windows Forms C++. I've placed my code(like adding event handler and some IO&String handling) inside the void InitializeComponent(void) function. It's stated that not to modify this function with any code editor. Will this result in any problem in the future? If so, Where should I place my own code? Excuse me,if it is a silly Question. I've not used Windows Forms before. Can any body suggest any online material for Windows Forms as a start up?

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        pix_programmer wrote:

        Where should I place my own code?

        Anywhere you like except places marked "do not modify".

        pix_programmer wrote:

        Excuse me,if it is a silly Question.

        So you are excused. This once. :)

        Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

        Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

        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