Exemplo n.º 1
0
        private CStudent GetStudent(string name)
        {
            if (name == "" || name == "无人")
            {
                return(null);
            }
            foreach (CStudent s in mstudent)
            {
                if (s.Name == name)
                {
                    return(s);
                }
            }
            CStudent stu = new CStudent(name);

            mstudent.Add(stu);
            return(stu);
        }
Exemplo n.º 2
0
 private void dgv_DragOver(object sender, DragEventArgs e)
 {
     Console.Write(".");
     if (e.AllowedEffect == (DragDropEffects.Move | DragDropEffects.Copy))
     {
         DataGridView dgv = (DataGridView)sender;
         e.Effect = DragDropEffects.None;
         Point p = dgv.PointToClient(new Point(e.X, e.Y));
         DataGridView.HitTestInfo droppos = dgv.HitTest(p.X, p.Y);
         if (droppos.RowIndex < 0 || droppos.ColumnIndex < 0)
         {
             return;
         }
         CStudent dropkv = (CStudent)dgv[droppos.ColumnIndex, droppos.RowIndex].Value;
         DataGridViewTextBoxCell dragcell = (DataGridViewTextBoxCell)e.Data.GetData(typeof(System.Windows.Forms.DataGridViewTextBoxCell));
         CStudent dragkv = (CStudent)dragcell.Value;
         if (dropkv == dragkv)
         {
             return;
         }
         e.Effect = DragDropEffects.Move;
     }
 }