private void deleteUserToolStripMenuItem_Click(object sender, EventArgs e) { if (usernameList.SelectedObject == null) { return; } string val = ((KeyValuePair <string, string>)usernameList.SelectedObject).Key; if (val == RegistryAccess.DefaultUsername) { MessageBox.Show("You can not remove default user from this list."); return; } if (MessageBox.Show("Are you sure to delete '" + val + "' from list?", "Delete User?", MessageBoxButtons.YesNo) == DialogResult.No) { return; } RegistryAccess.DeleteUserid(val); LoadUsernames(); }