简体   繁体   中英

C# WinForms events not firing

As the title suggests, I cannot get a single event to fire from an MDIChild application. No mouse event, no load, keypress, nothing at all.

 private void btnSave_Click(object sender, EventArgs e)
        {Console.WriteLine("Clicked");}

this.btnSave.Click += new System.EventHandler(this.btnSave_Click);

Selected the event from the properties window, manually subscribed to the event and yet nothing at all.

As the comments suggest you could insert a break point to see if these events are being fired.

From the information in your question it looks like the issue is that you're calling

Console.WriteLine

From a Winforms application.If you want to see somethng appear you could try

MessageBox.Show("Clicked")

Console applications would show Console.WriteLine, but the fact that you have buttons suggests a WinForms app.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM