MDI 家长控制的 if 条件 [英] if condition for MDI Parent Control
问题描述
我有一个 mdi 父母和一个 mdi 孩子,我想知道我是否应该设置什么条件来调用正确的类.
i have an mdi parent and mdi child and i want to know if what condition should i put to call the right class for this .
senario 是我在 mdi 父级 (selectall) 中有一个按钮,然后我想将该按钮用于活动的 mdi 子级.
senario was i got a button in mdi parent (selectall) then i want to use that button for the active mdi child .
让我们说:
private void iSelectAll_ItemClick(object sender, e)
{
Form DtexteditoR = new DtexteditoR();
//DtexteditoR.Show();
if (DtexteditoR.MdiChild == true)
{
rtb.SelectAll();
}
}
但是一个错误
运算符 == 不能应用于类型的操作数'System.Windows.Forms.Form' 和 'bool'
Operator == cannot be applied to operands of type 'System.Windows.Forms.Form' and 'bool'
出现……我该怎么办?
推荐答案
您需要 Form.IsMdiChild
检查表单是否为 Mdi Child.
You need Form.IsMdiChild
to check if the form is Mdi Child.
获取指示表单是否为多文档的值接口 (MDI) 子窗体.
Gets a value indicating whether the form is a multiple-document interface (MDI) child form.
private void iSelectAll_ItemClick(object sender, e)
{
Form DtexteditoR = new DtexteditoR();
//DtexteditoR.Show();
if (DtexteditoR.IsMdiChild)
{
rtb.SelectAll();
}
}
要检查 MdiContainer
使用 Form.IsMdiContainer 属性
To check for MdiContainer
use Form.IsMdiContainer Property
这篇关于MDI 家长控制的 if 条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!