我们可以使用继承形式的对象作为MDI Form的子代吗?我收到了错误。 [英] Can we use object of inherited form as a child of MDI Form ? I am getting errors.

查看:134
本文介绍了我们可以使用继承形式的对象作为MDI Form的子代吗?我收到了错误。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我已将Form1继承到Form2。我想将Form2显示为MDI子。但是,在显示它时会抛出创建窗口句柄时出错。。



Hello,

I have inherited Form1 to Form2. I want to show Form2 as MDI child. But, while showing it throws "Error creating window handle.".

Form1: Form
{
}

Form2: Form1
{
}

MdiForm: Form
{
     Form2 objForm = new Form2();
     objForm.MdiParent = this;
     objForm.WindowState = FormWindowState.Maximized;
     objForm.ControlBox = false;
     objForm.ShowIcon = false;
     objForm.Show();
}





这里,Form2对象作为单独的表单工作正常,但如果我将它作为子表单MDI。我没有得到任何错误日志。



请帮忙解决。在此先感谢。



Here, Form2 object is working fine as a individual form but its not working if i make it child form of MDI. I did not get any error log.

Please help to resolve it. Thanks in advance.

推荐答案

从那个小的,我们可以真正回答你的问题。

但是有几件事你可以检查。

首先,确保MdiForm实例的IsMDIContainer属性设置为true。

然后,检查您执行上面显示的代码的确切位置:if MdiForm实例尚未显示,然后它将没有句柄,因此MDI chiold将显示问题。

尝试将代码移动到MdiForm.Shown事件并看到它修复它 - 父母应该在那个阶段有一个句柄。
From that little, we can;t really answer your problem.
But there are a couple of things you can check.
First, make sure that the MdiForm instance has the IsMDIContainer property set to true.
Then, check exactly where you are executing the code you show above: if the MdiForm instance has not been shown yet, then it won't have a handle, so the MDI chiold will have problems displaying.
Try moving the code to the MdiForm.Shown event and see it that fixes it - the parent should have a handle by that stage.


这篇关于我们可以使用继承形式的对象作为MDI Form的子代吗?我收到了错误。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆