Reputation: 366
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 was i got a button in mdi parent (selectall) then i want to use that button for the active mdi child .
lets say:
private void iSelectAll_ItemClick(object sender, e)
{
Form DtexteditoR = new DtexteditoR();
//DtexteditoR.Show();
if (DtexteditoR.MdiChild == true)
{
rtb.SelectAll();
}
}
but a error
Operator == cannot be applied to operands of type 'System.Windows.Forms.Form' and 'bool'
appears ... what should i do?
Upvotes: 0
Views: 532
Reputation: 339
write a form class that inherited from Form class and implement following method( MasterForm) : method in master form class of childs : selectAll
public class MasterForm:Form
{
public virtual void SelectAll()
{
}
}
each child form must inhertated from MasterForm and override SelectAll Method
public class Child1:MasterForm
{
public override void SelectAll()
{
this.rtb.SelectAll();
}
}
in parent form in button click body
if(this.ActiveMdiChild!=null)
{
MasterForm frm =(MasterForm) this.ActiveMdiChild;
frm.SelectAll();
}
Upvotes: 0
Reputation: 223362
You need Form.IsMdiChild
to check if the form is Mdi Child.
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();
}
}
To check for MdiContainer
use Form.IsMdiContainer Property
Upvotes: 3