Exemplo n.º 1
0
 public virtual void Form_KeyDown(object sender, KeyEventArgs e)
 {
     // 按键事件
     if (e.KeyCode == Keys.F5)
     {
         // F5刷新,重新加载窗体
         this.FormOnLoad();
     }
     else
     {
         // 按了回车按钮处理光标焦点
         if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Return)
         {
             if ((this.ActiveControl is TextBox) || (this.ActiveControl is ComboBox) || (this.ActiveControl is CheckBox))
             {
                 if ((this.ActiveControl is TextBox) && ((TextBox)this.ActiveControl).Multiline)
                 {
                     return;
                 }
                 SendKeys.Send("{TAB}");
             }
         }
     }
     if (e.KeyCode == Keys.F10)
     {
         Image    iA = new Bitmap(this.Width, this.Height);
         Graphics g  = Graphics.FromImage(iA);
         g.CopyFromScreen(new Point(this.Location.X, this.Location.Y), new Point(0, 0), new Size(this.Width, this.Height));
         Clipboard.SetImage(iA);
         FrmPrint frmPrint = new FrmPrint();
         frmPrint.ShowDialog();
     }
 }
Exemplo n.º 2
0
 public virtual void Form_KeyDown(object sender, KeyEventArgs e)
 {
     // 按键事件
     if (e.KeyCode == Keys.F5)
     {
         // F5刷新,重新加载窗体
         this.FormOnLoad();
     }
     else
     {
         // 按了回车按钮处理光标焦点
         if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Return)
         {
             if ((this.ActiveControl is TextBox) || (this.ActiveControl is ComboBox) || (this.ActiveControl is CheckBox))
             {
                 if ((this.ActiveControl is TextBox) && ((TextBox)this.ActiveControl).Multiline)
                 {
                     return;
                 }
                 SendKeys.Send("{TAB}");
             }
         }
     }
     if (e.KeyCode == Keys.F10)
     {
         Image iA = new Bitmap(this.Width, this.Height);
         Graphics g = Graphics.FromImage(iA);
         g.CopyFromScreen(new Point(this.Location.X, this.Location.Y), new Point(0, 0), new Size(this.Width, this.Height));
         Clipboard.SetImage(iA);
         FrmPrint frmPrint = new FrmPrint();
         frmPrint.ShowDialog();
     }
 }