-5

I've been looking for some time now to find (I know it sounds stupid) how I can call some code when I start my application. I'm using C# on Windows Forms. I know this all sounds stupid but I usually just use Unity3D which has a simple method:

void Start() 
{
    //Whatever goes here
}

I'm trying to make a web browser.

mason
  • 31,774
  • 10
  • 77
  • 121
Hayden
  • 1
  • 1
  • Why are you building a web browser? – Neo Jul 25 '17 at 16:33
  • are you talking about form's `Load` event? – Oscar Martinez Jul 25 '17 at 16:42
  • 1
    If only there was a place to find documentation on Winforms, or perhaps a search engine which you could use to find the [entry point to a Winforms application](https://stackoverflow.com/questions/8992837/where-is-the-main-method-in-a-forms-application). –  Jul 25 '17 at 16:59

2 Answers2

0

you can put code in the winforms generated main

    static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        // you code goes here
        Application.Run(new MainForm());
    }

or in the load event of the MainForm

pm100
  • 48,078
  • 23
  • 82
  • 145
-1

You can go to global file and put the code inside Application start event.

If you want to run the code when a certain webpage opens, u can put it in the load event created in the .cs file of the page.