C # WeifenLuo.WinFormsUI.Docking.dll application problem subset form Access parent form method

Source: Internet
Author: User

The parent form content that needs to be obtained in the subform method as

Checkformisopen
PrivateFrmmenu Frmmenu =NewFrmmenu ();  PublicFrmmain () {InitializeComponent (); }        Private voidFrmmain_load (Objectsender, EventArgs e) {FRMMENU.P_FM= This; Frmmenu.show ( This. Dockpanelmain); }                      Public BOOLCheckformisopen (stringformname) {            BOOLRemark =false;  for(intA =0; A <Base. Mdichildren.length; a++)            {                if(FormName. Equals (Base. Mdichildren[a]. GetType (). Namespace +"."+Base. Mdichildren[a]. GetType (). Name)) {Base. Mdichildren[a].                    Activate (); Remark=true; }            }            returnremark; }

Subform:

usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Text;usingSystem.Windows.Forms;usingWeifenLuo.WinFormsUI.Docking;namespacee24tt{ Public Partial classfrmmenu:dockcontent { PublicFrmmenu () {InitializeComponent (); }        //formsub:        Privatefrmmain FM;  Publicfrmmain p_fm {Get{returnFM;} Set{fm =value;} }        Private voidFrmmenu_load (Objectsender, EventArgs e)        {Trvmenu.expandall (); }        Private voidTrvmenu_afterselect (Objectsender, TreeViewEventArgs e) {            Try            {                //formsub://when it is necessary to refresh its caller (parent)                                   if( This. trvMenu.SelectedNode.Text! =NULL)                {                    if( This. trvMenu.SelectedNode.Tag! =NULL)                    {                        stringFormName = This. trvMenu.SelectedNode.Tag.ToString (); if(!FM. Checkformisopen (FormName)) {FM.                        Openchildform (FormName); }}} FM. Text="the 24TT setting"+ This. TrvMenu.SelectedNode.Text; }            Catch { }        }    }}

This method solves the problem of parent-child form passing value

Attribute method
Formfather:
Need to have a public refresh method
public void Refresh_method ()
{
//...
}
When called
Formsub F2 = new Formsub ();
F2. P_F1 = this; Emphasis, assigning values to the subform corresponding property
F2. Show ();

Formsub:
Private Formfather p_f1;
Public Formfather p_f1
{
Get{return p_f1;}
SET{P_F1 = value;}
}
When refreshed
P_f1. Refresh_method ();

C # WeifenLuo.WinFormsUI.Docking.dll application problem subset form Access parent form method

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.