try to hide form instead of closing it, using
private void Playlist_FormClosed(object sender, FormClosedEventArgs e)
{
if (e.CloseReason == CloseReason.FormOwnerClosing) //if closed by aplication
{
this.Close();
}
if (e.CloseReason == CloseReason.UserClosing) //if closed by user
{
this.Hide();
}
}
but it's still close it, if User click Close.
Use FormClosing instead of FormClosed. There you can do e.Cancel = true; to achieve what you need. The problem is that the form is already Closed by the time FormClosed event occurs, so Hide() won't do any good and you won't be able to use this object in the future, if you try it with FormClosed event.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With