private void Change_Students_Click(object sender, EventArgs e) { string value = ""; if (txtValue.Text == "") { MessageBox.Show("The value can't be nothing"); return; } if (!IsInt(txtValue.Text)) { MessageBox.Show("Not a valid value(Only number, No comma's)"); return; } try { value = txtValue.Text; ListViewItem item = listViewActivity.SelectedItems[0]; SomerenLogic.Activity_Service activity_Service = new Activity_Service(); activity_Service.UpdateStudent(value, int.Parse(item.Text)); } catch (ArgumentOutOfRangeException) { MessageBox.Show("Select an Item"); return; } showPanel("Activity"); }