示例#1
0
        private T GetSelectedItem <T>() where T : class
        {
            int i   = Gridview.GetSelectedRows().FirstOrDefault();
            T   obj = Gridview.GetRow(i) as T;

            return(obj);
        }
示例#2
0
 private void DatagridviewMain_ProcessGridKey(object sender, KeyEventArgs e)
 {
     if (e.KeyData == Keys.Delete)
     {
         DialogResult result = FormUtility.MsgDelete();
         if (result == DialogResult.Yes)
         {
             int    i   = Gridview.GetSelectedRows().FirstOrDefault();
             object obj = Gridview.GetRow(i) as object;
             if (obj == null)
             {
                 return;
             }
             DeleteRow <object>(obj);
             Gridview.DeleteRow(i);
         }
     }
     e.Handled = true;
 }