3
I have the following on a form:
public form1()
{
InitializeComponent();
this.FormClosing += new FormClosingEventHandler(this.confirmarFechamento_FormClosing);
}
private void confirmarFechamento_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.UserClosing)
{
var result = MessageBox.Show(this, "Você tem certeza que deseja sair?", "Confirmação", MessageBoxButtons.YesNo);
if (result != DialogResult.Yes)
{
e.Cancel = true;
}
}
}
How could I turn this into a class and just call it a method?
In case it would be class confirmarFechamento
who has the method confirmarFechamento
, and in Form1 would have the call of the method confirmarFechamento
.
What would be the purpose of doing this? You want to take advantage of the method in more than one form, that’s it?
– Conrad Clark
If so, you could make a Baseform and put this event in it
– Tafarel Chicotti
What is your goal? use the method in several places?
– Marciano.Andrade
Yes, I want to take advantage of the method, use in several different classes.
– ptkato