I am creating a simple media player app and I am encountering a strange issue...
If you look to the top right I have a close button, and to the bottom right , a cancel button. Both serve the same function ( to close this window ) .
The code handling this is as follows ( I added both button's click event to the exact same event handler )
private void ExitApp_Click(object sender, EventArgs e) {
Close();
}
EDIT : Adding entire code
using System;
using System.IO;
using System.Windows.Forms;
namespace AnimePlayer {
public partial class AddAnime : Form {
public AddAnime() {
InitializeComponent();
}
private void ExitApp_Click(object sender, EventArgs e) {
this.Close();
}
private void bunifuThinButton21_Click(object sender, EventArgs e) {
if (AnimeLocation.ShowDialog() == DialogResult.OK) {
AnimeLocationLabel.Text = AnimeLocation.SelectedPath;
}
}
private void bunifuThinButton22_Click(object sender, EventArgs e) {
if (PictureLocation.ShowDialog() == DialogResult.OK) {
PictureLocationLabel.Text = Path.GetFullPath(PictureLocation.FileName);
}
}
private void bunifuFlatButton1_Click(object sender, EventArgs e) {
// Create and save anime object
}
}
}
All works perfectly as intended when clicking the top right cross, the window closes and returns to the main window.
This is not the case when using the bottom right button, which instead throws a NullReferenceException on Program.cs here :
Application.Run(new Main());
I have tried using seperate event handlers, Dispose() instead of Close() but the result stays the same.
Any help will be greatly appreciated ( I'm pretty sure this is just something I am not aware of )