tcop
tcop

Reputation: 381

Proper way of initializing components

The VS IDE has automatically created a designer class which is fine. I want to parse a text file and initialize the .text value of every component based on a user setting on runtime. It seems impossible to do it inside the designer.cs file as it is regenerated and my code gets overwritten but on the other hand this seems to be the proper thing to do since there should be just one InitializeComponent method. Any ideas?

Upvotes: -1

Views: 473

Answers (1)

Aleksa Ristic
Aleksa Ristic

Reputation: 2499

How i like to do it is create function:

private void SecondInitialize()
{
    //Custom controls initializition
}

and call it after InitializeComponent()

public YourForm()
{
    InitializeComponent();
    SecondInitialize();
}

Upvotes: 1

Related Questions