mdiform焦点问题 窗体在属性IsMdiContainer为true时,是不能接受keydown事件的。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 MainForm.cs:public MainForm(){ parentWindow = this;}private void MainForm_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e){ switch (e.KeyCode) { case System.Windows.Forms.Keys.F2: OpenFrmRent(); break; case System.Windows.Forms.Keys.F3: OpenFrmRent(); break; default: break; }}private void OpenFrmRent(){ FrmRent frm=new FrmRent(parentWindow); frm.Show(); }FrmRent.cs:public FrmRent(MainForm parent){ // // Win 窗体设计器支持所必需 // InitializeComponent(); this.MdiParent = parent; //使该视图成为主窗口的 Mdi 子级}private void FrmRent_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e){ switch (e.KeyCode) { case System.Windows.Forms.Keys.F5: this.Dispose(true); break; }}protected override void Dispose( bool disposing ){ ActiveParent(); bool tmpBool=this.MdiParent.Focused; if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose(disposing ); }上面就是代码第一次导入的时候,IsMdiContainer=true,但是它是可以接受焦点事件的,可是打开子窗体的时候就丢失了焦点,请问如何让它找回焦点呢? 第一次导入的时候,IsMdiContainer=true,但是它是可以接受keydown事件的,可是打开子窗体再关闭后,父窗体就丢失了焦点,请问如何让它找回焦点呢? 捕获按键:只要把父窗体的KeyPreview变为true即可。 BBS怎么做 使用oledb读取Excel问题 Worksheet ws.get_Range()不太符合我的数据需求 屏幕还是出现闪屏,希望有人能解决(附源程序) 请问如何给自动生成的按钮改变图片呢? 程序无法退出,求解! Infragistics.UltraWinGrid控件邦定列问题 Access升级到SQL Server2000的简便方法? 如何解决winforms刷新问题? Click Once部署问题 初学,求C#电子书 怎样将16进制的转成Unicode?
public MainForm()
{
parentWindow = this;
}
private void MainForm_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
switch (e.KeyCode)
{
case System.Windows.Forms.Keys.F2:
OpenFrmRent();
break;
case System.Windows.Forms.Keys.F3:
OpenFrmRent(); break;
default:
break;
}
}
private void OpenFrmRent()
{
FrmRent frm=new FrmRent(parentWindow);
frm.Show();
}FrmRent.cs:
public FrmRent(MainForm parent)
{
//
// Win 窗体设计器支持所必需
//
InitializeComponent();
this.MdiParent = parent; //使该视图成为主窗口的 Mdi 子级
}private void FrmRent_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
switch (e.KeyCode)
{
case System.Windows.Forms.Keys.F5:
this.Dispose(true);
break;
}
}
protected override void Dispose( bool disposing )
{
ActiveParent();
bool tmpBool=this.MdiParent.Focused;
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose(disposing );
}上面就是代码
第一次导入的时候,IsMdiContainer=true,但是它是可以接受焦点事件的,可是打开子窗体的时候就丢失了焦点,请问如何让它找回焦点呢?