在一个MDI中,新开的子窗口不能接收KEYDOWN事件 将子窗口的KeyPreview设置为 True. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 试一试打开这个窗体,最后不行,贴上代码来.打开代码: 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"); } }} FTP上传很慢,有没什么好的办法! 水晶报表 参数 使用XmlSerializer序列化对象时,如何去掉空元素? C#如何调用不同窗体中的事件? VS2005 C# GridView中的编辑问题 结构 是不是跟类一样 系统会自己会回收垃圾? api函数定义的问题 关于DataGridView的问题~~ 请问读文件时怎样一次读2个byte?c#中想把int转换成16进制形式表示该怎样做?(急) wpf中ObservableCollection集合中add方法为什么不触发属性中的set方法 关于微软认证考试 程序写到这里就写不下去了,请大家帮忙!
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");
}
}
}