Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Form1_Load not firing even after adding handler

It's been a long time since I've dabbled with C#, but I'm having a heck of a time getting my form_load to fire. This is the most simple thing I can't imagine why it won't fire! Any assistance would be appreciated.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AppName_v4._0___TestRoom_Addon{
    public partial class Form1 : Form{

        public Form1() {
            InitializeComponent();
            this.Load += new EventHandler(this.Form1_Load); //FIRES!
        }

        private void Form1_Load(object sender, EventArgs e) {
            webKitBrowser1.Dock = DockStyle.Fill; //DOES NOT FIRE!
            webKitBrowser1.Navigate("http://192.168.0.10/?zoneid=11");
        }
    }
}

UPDATE

  • I have used breakpoints to verify the line is not hit
  • The form does show Screenshot of resulting Form

I have also tried the following with no success:

namespace AlphaEntry_v4._0___MailRoom_Addon{
    public partial class Form1 : Form{

        public Form1() {
            InitializeComponent();

        }

        protected override void OnLoad(EventArgs e)
        {
            webKitBrowser1.Dock = DockStyle.Fill;
            webKitBrowser1.Navigate("http://192.168.0.10/?zoneid=11");

            base.OnLoad(e);
        }
    }
}

UPDATE #2 I was able to get this working by removing and re-adding the references to the WebKit Control. Not sure what happened. Thanks everyone.

like image 948
Dutchie432 Avatar asked Nov 28 '22 12:11

Dutchie432


1 Answers

I just worked out the same issue. The root cause should be that Form1_Load event was not fired while Form1 was loaded. Just open the Form1 in Designer view, click the Form1's title, click 'Event' tag under property of Form1, find 'Load' in the property list, you'll find a list of events on right hand of it. Select 'Form1_Load', rebuild it. You can verify by choosing any event other than Form1_Load to check if Form1_Load() being called or not.

like image 85
Stan Huang at Taiwan Avatar answered Dec 24 '22 11:12

Stan Huang at Taiwan