private void submitBTN_Click(object sender, EventArgs e) { Boolean nameExist = false; // Check if the user fill in the name if (nameTB.Text == "") { MessageBox.Show("Please enter your name!", "Info"); } else { // Check if the chosen name exist for (int i = 0; i < player.getSize(); i++) { if (nameTB.Text == player.getscore(i).getName()) { nameExist = true; } } if (nameExist) { MessageBox.Show("This name has been taken, please use another name!", "Info"); } else { checkSubmit = true; StreamWriter sw = createFile(); Indvscore stat = new Indvscore(nameTB.Text, Convert.ToInt32(scoreLBL.Text)); player.Addplayer(stat); // Display all the scores entered for (int i = 0; i < player.getSize(); i++) { sw.WriteLine(player.getscore(i).getName() + "," + player.getscore(i).getScore()); } sw.Close(); // Display the popup MessageBox.Show("Your score has been submitted!", "Info"); // Refresh Data List refreshDGV(); // Disable submit button submitBTN.Enabled = false; } } }