コード例 #1
0
        }//---------------------

        //###########################################END BUTTON btnClose EVENTS####################################################

        //###########################################LISTVIEW lsvMajorExam EVENTS#####################################################
        //event is raised when the checked is changed
        private void lsvMajorExamItemChecked(object sender, ItemCheckedEventArgs e)
        {
            if (e.Item.Checked && _studentManager.IsClearanceIncluded(e.Item.SubItems[1].Text))
            {
                this.lsvMajorExam.ItemChecked -= new ItemCheckedEventHandler(lsvMajorExamItemChecked);

                _studentManager.InitializeInsertedExamSchedule(e.Item.SubItems[1].Text, e.Item.Checked);

                Int32 index = 0;

                foreach (ListViewItem item in lsvMajorExam.Items)
                {
                    if (item.Checked && index != e.Item.Index)
                    {
                        item.Checked = false;

                        _studentManager.InitializeInsertedExamSchedule(item.SubItems[1].Text, item.Checked);
                    }

                    index++;
                }

                this.lsvMajorExam.ItemChecked += new ItemCheckedEventHandler(lsvMajorExamItemChecked);
            }
            else if (e.Item.Checked && !_studentManager.IsClearanceIncluded(e.Item.SubItems[1].Text))
            {
                this.lsvMajorExam.ItemChecked -= new ItemCheckedEventHandler(lsvMajorExamItemChecked);

                _studentManager.InitializeInsertedExamSchedule(e.Item.SubItems[1].Text, e.Item.Checked);

                Int32 index = 0;

                foreach (ListViewItem item in lsvMajorExam.Items)
                {
                    if (_studentManager.IsClearanceIncluded(item.SubItems[1].Text))
                    {
                        item.Checked = false;

                        _studentManager.InitializeInsertedExamSchedule(item.SubItems[1].Text, item.Checked);
                    }

                    index++;
                }

                this.lsvMajorExam.ItemChecked += new ItemCheckedEventHandler(lsvMajorExamItemChecked);
            }
            else
            {
                this.lsvMajorExam.ItemChecked -= new ItemCheckedEventHandler(lsvMajorExamItemChecked);

                _studentManager.InitializeInsertedExamSchedule(e.Item.SubItems[1].Text, e.Item.Checked);

                this.lsvMajorExam.ItemChecked += new ItemCheckedEventHandler(lsvMajorExamItemChecked);
            }

            this.btnPrint.Enabled = this.lnkFilter.Enabled = this.lsvMajorExam.CheckedItems.Count <= 0 ? false : true;
        }//-----------------------