本文介绍了表单如何在父表单的KeyUp事件中使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 你好! 我有一个问题,首先,我有一个父表单(mainForm),并且在这里有一个KeyUp事件(private void MainForm_KeyUp(object sender,KeyEventArgs e)) 其次,我的子格式(Frm2)比openDialog命令打开, **现在我需要Frm2可以在MainForm_KeyUp中使用。** 真的,Frm2来到MainForm_KeyUp函数,但KeyEventArgs e = Keys.Enter 而不是我所有的数字。 评论:KeyEventArgs由磁卡读卡器填充。 这是代码: hello!I have a problem,First, I have a parent form ("mainForm") and in this there is a KeyUp event(private void MainForm_KeyUp(object sender, KeyEventArgs e))Second, I have child form(Frm2) than opened by openDialog command,**Now I need that Frm2 can use in MainForm_KeyUp.**Really, Frm2 comes to MainForm_KeyUp function, but KeyEventArgs e = Keys.Enterand not all my numbers.A comment: the KeyEventArgs Filling up by magnetic Card reader.This is the code:private void MainForm_KeyUp(object sender, KeyEventArgs e) { MessageBox.Show(e.KeyCode.ToString()); if (e.KeyData == Keys.Enter) { MessageBox.Show("End"); }} 当我从mainForm中读取读卡器时,我得到:12345END,但来自Frm2,我得到结束。为什么KeyEventArgs参数没有更多的键?我也必须从frm2获得12345END 我非常感谢您的试用帮助!!! Soh Wheמ I swip the card in the reader from the mainForm, I get : "12345END", but from the Frm2, I get "END". why the KeyEventArgs parameter not have more keys? I have to get "12345END" also from frm2I'm really thankful for your trial to help!!!Soh推荐答案 public void Form1_KeyUp(object sender, KeyEventArgs e){ MessageBox.Show(e.KeyValue.ToString());} 以儿童形式,您可以使用此方法。 And in child form you can access this method.private void Form2_KeyUp(object sender, KeyEventArgs e){ Form1 parentForm = new Form1(); parentForm = (Form1) this.Owner; parentForm.Form1_KeyUp(sender, e);} 这篇关于表单如何在父表单的KeyUp事件中使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-29 21:49