Name of the function does not necessary need to match button name, it's just the convention which makes it easier to understand which element is bound to which function on which event.
If you enter the FormName.Designer.cs
file, you will find InitializeComponent
function which contains the properties setup of all form elements, including their event binding. For example, you will probably have something like this over there:
this.button1.Click += new System.EventHandler(this.button1_Click);
where button1
is name of the element, Click
is name of the event of that element and button1_Click
is the name of the function handling that event.
If you're in the design mode of the form FormName.cs [Design]
you can find the lightning icon inside the VisualStudio Properties
window (one of the tabs next to your Solution Explorer
tab). Under that icon, you will find the list of all the possible events of the currently selected element in your designer. On the example of your button it should look like this:
You can handle the event binding either here or inside your FormName.Designer.cs
file, but it's preferable through this view because content of the Designer
file is automatically generated. InitializeComponent
function is then called inside the constructor of your form which initializes the form based on the setup of your designer file.
private void yournewbuttonname_Click(object sender, EvenArgs e)
manually change it to that? – Viglione