Could someone explain the reason why the code below does not work?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.
You need to bind the button click to the event of button click! :)
button1.Click += button1_Click;
Make sure attached the event Click
with your button. You can do it by going to designer, double click the button, it will create the event handler for you in the code. You can also attach the event handler in your Form Constructor like:
public Form1()
{
InitializeComponent();
button1.Click += button1_Click;
}
You can go to the designer, right click on Button1
, click properties, Got to events and there you can attach the event handler: