private void SubForm_KeyDown(object sender, KeyEventArgs e) { Control control = this.ActiveControl; // 取得できた場合のみ、そのコントロールの名前を表示する if (control != null) { //MessageBox.Show(control.Name); } Form1 f = new Form1(); switch (e.KeyCode) { case Keys.Enter: if (control.Name == "textBox2"){ f.NextForm(); break; } if (!e.Control) { this.SelectNextControl(this.ActiveControl, !e.Shift, true, true, true); } break; case Keys.Up: if (control.Name == "textBox1") { f.PreviousForm(); break; } if (!e.Control) { this.SelectNextControl(this.ActiveControl, false, true, true, true); } break; default: break; } }