将子窗口的KeyPreview设置为 True.

解决方案 »

  1.   

    试一试打开这个窗体,最后不行,贴上代码来.打开代码:
    Form4 f4 = new Form4();
    f4.KeyPreview = true;
    f4.MdiParent = this;
    f4.Show();
    ----------------------------------using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;namespace MDITest
    {
    /// <summary>
    /// Form4 的摘要说明。
    /// </summary>
    public class Form4 : System.Windows.Forms.Form
    {
    /// <summary>
    /// 必需的设计器变量。
    /// </summary>
    private System.ComponentModel.Container components = null; public Form4()
    {
    //
    // Windows 窗体设计器支持所必需的
    //
    InitializeComponent(); //
    // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
    //
    } /// <summary>
    /// 清理所有正在使用的资源。
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if(components != null)
    {
    components.Dispose();
    }
    }
    base.Dispose( disposing );
    } #region Windows Form Designer generated code
    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
    // 
    // Form4
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
    this.ClientSize = new System.Drawing.Size(480, 318);
    this.KeyPreview = true;
    this.Name = "Form4";
    this.Text = "Form4";
    this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Form4_KeyDown); }
    #endregion private void Form4_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
    {
    MessageBox.Show("Key Down");
    }
    }
    }