I have the following in 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 as a method?
In case it would be class confirmarFechamento
that has method confirmarFechamento
, and in form1 would have the call of method confirmarFechamento
.