コード例 #1
0
 private void BtnUpdate_Click(object sender, EventArgs e)            //event to update selected score
 {
     if (listBoxScores.SelectedIndex != -1)                          //if the selected index of listbox is not -1
     {
         frmUpdateScore updateScoreForm = new frmUpdateScore();      //declare instance of form update score
         updateScoreForm.newScore = updatedList[(listBoxScores.SelectedIndex)];
         updateScoreForm.Show();                                     //show form
         updateScoreForm.VisibleChanged += updateFormVisibleChanged; //change visibility to form update score
     }
 }
コード例 #2
0
        private void updateFormVisibleChanged(object sender, EventArgs e)       //method for frmUpdateScore visibility change
        {
            frmUpdateScore updateForm = (frmUpdateScore)sender;                 //declare instance of form update score

            if (!updateForm.Visible & updateForm.DoUpdate())                    //declare new instance of frmUpdateScore
            {
                updatedList[listBoxScores.SelectedIndex] = updateForm.newScore; //update the list with new score frmUpdateScore
                FillListBoxScores();                                            //call fill list box method
                updateForm.Dispose();                                           //dispose of the form
                this.Show();
            }
        }