Data transfer between MDI forms, subsidiaries

xiaoxiao2021-03-06  38

There is a MDI main form (MAINFORM), a child form (Childform) and another sub-form (Listform),

The process they created is like this:

Click on a button of the main form Mainform; display ChildForm, click on the ChildForm, display listform, and save a variable while getting saved variables.

// Master's code

Public Class Mainform

{

....

Private static childform;

Private static listform listform;

Private static string Str;

/ / Generator Subform ChildForm

Private void button_1 (Object Sender, System.EventArgs E)

{

Childform = getChildForm ();

ChildForm.mdiparent = this;

ChildForm.show ();

}

Private void getChildform ()

{

if (ChildForm == Null)

{

ChildForm = new childform ();

}

Return CHildForm;

}

Public void showlistform ()

{

Listform = getListForm ();

Listform.mdiparent = this;

Listform.show ();

}

Private void getListform ()

{

IF (Listform == Null)

{

Listform = new listform ();

}

Return ListForm;

}

Public Static String Uid

{

Get {return str;}

SET {str = value;}

}

}

// Subform Childform

Public Class ChildForm

{

...

Private void button1_click (...)

{

String str = "abc";

Mainform.UID = STR;

Mainform mf = (mainform) this.mdiparent;

Mf.showlistform ();

}

}

// Form Listform

Public Class ListForm

{

Private void getdata ()

{

String str = mainform.UID

Messagebox.show (STR);

}

}

转载请注明原文地址:https://www.9cbs.com/read-63642.html

New Post(0)