Пример #1
0
        private void computersDataGrid_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            string selectedComputer = computersDataGrid.CurrentRow.Cells[0].Value.ToString();

            if (e.ColumnIndex == 3)
            {
                Computer currentComputer = classroom.Computersinclassroom.Find(cname => cname.Computername == selectedComputer);
                //open a message box on top of THIS window
                MessageBox.Show(this, currentComputer.ToString());
            }
            if (e.ColumnIndex == 4)
            {
                Computer currentComputer = classroom.Computersinclassroom.Find(cname => cname.Computername == selectedComputer);


                if (currentComputer.GetType().Equals(typeof(Laptop)))
                {
                    Laptop           currentLaptop = (Laptop)currentComputer;
                    ClassroomChooser chooser       = new ClassroomChooser(currentLaptop, classroom);

                    chooser.ShowDialog();
                    filldatagrid();
                }
                else
                {
                    MessageBox.Show(this, "Only laptops may be moved");
                }
            }
        }
Пример #2
0
        private void computersDataGrid_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            string selectedComputer = computersDataGrid.CurrentRow.Cells[0].Value.ToString();

            if (e.ColumnIndex == 3)
            {
                Computer currentComputer = classroom.Computersinclassroom.Find(cname => cname.Computername == selectedComputer);
                //open a message box on top of THIS window
                MessageBox.Show(this,currentComputer.ToString());
            }
            if (e.ColumnIndex == 4)
            {
                Computer currentComputer = classroom.Computersinclassroom.Find(cname => cname.Computername == selectedComputer);

                if (currentComputer.GetType().Equals(typeof(Laptop)))
                {
                    Laptop currentLaptop = (Laptop)currentComputer;
                    ClassroomChooser chooser = new ClassroomChooser(currentLaptop, classroom);

                    chooser.ShowDialog();
                    filldatagrid();
                }
                else
                {
                    MessageBox.Show(this, "Only laptops may be moved");
                }

            }
        }