コード例 #1
0
        private void btnDel_Click(object sender, EventArgs e)
        {
            DialogResult question = MessageBox.Show("Are you sure?", "", MessageBoxButtons.YesNo);

            if (question == DialogResult.Yes)
            {
                //=========================  Book-un silinmesi ====================================
                // downcast edirik ve BookComboBox secilmish book ID nomresini bookId-ye veririk
                string bookId = ((BookComboBox)cmbBookList.SelectedItem).Value;

                // BookList-den secilmish book ID-ye gore tapib veririk Book tipinde bookForDelete-e
                // bir nov apcast olunur ki Book-un icinden lazim olana catsin
                Book bookForDelete = BookList.GetBookById(bookId);

                // BookList-den Book classina girib Books siyahisindan
                // ID-ci uyqun geleni silirik
                BookList.Books.Remove(bookForDelete);
            }

            UpdateBookList();
        }