I have a MDIChild
form ,Normal Form called form1
inherited from MDIChild
form and MDIParent
form ,there is a tool bar top of the MDIParent
form
in that tool bar there is a New button, when I click on new button it loads the Form1
below the tool bar inside the parent form
There is a TextBox
inside the form1
and when I click the save button the value of the TextBox
should be shown in a MessageBox
by calling its function,
But the thing is I cant access the TextBox
Text
property??
And my MDIParent form code is
public partial class MDIParent1 : Form
{
// private int childFormNumber = 0;
MdiClient mdi = null;
string fname;
public MDIParent1()
{
InitializeComponent();
foreach (Control c in this.Controls)
{
if (c is MdiClient)
{
mdi = (MdiClient)c;
break;
}
}
}
private void load_form(object form)
{
foreach (Form f in mdi.MdiChildren)
{
f.Close();
}
if (form == null)
return;
((Form)form).MdiParent = this;
((Form)form).Show();
((Form)form).AutoScroll = true;
fname = ((Form)form).Name;
}
private void newToolStripButton_Click(object sender, EventArgs e)
{
load_form(new Form1());
}
private void saveToolStripButton_Click(object sender, EventArgs e)
{
if (fname == "Form1")
{
Form1 f1 = new Form1();
f1.show_message();
}
}
In my form1 code is
public void show_message()
{
MessageBox.Show(textBox1.Text);
}
My MDIChild form code is
public mdichild()
{
InitializeComponent();
this.Load += new EventHandler(this.mdichild_Load);
}
private void mdichild_Load(object sender, EventArgs e)
{
this.ControlBox = false;
this.WindowState = FormWindowState.Maximized;
this.BringToFront();
int h = Screen.PrimaryScreen.Bounds.Height;
int w = Screen.PrimaryScreen.Bounds.Width;
this.MinimumSize = new Size(w, h);
}
Can Anyone help me?