Hi to all,
I have 3 dialogs which are Parent, Dialog and Child. When I press My Parent dialog's menu I come across with my dialog box. Everything ok for now. But when I press the button on dialog I want my child dialog inside the parent dlg box. I think I made something wrong the code runs without any errors but doesn't make what I want??? Might be a logic failure in somewhere. This trashed all my day (I brainstrom and checked lots of articles about forms...) But couldn't get a result. So any help would be greatly appreciated. I am posting all my 3 file(Sorry for the pollution)
Thank you,
Cem Louis
/////////////
//Parent.cs//
/////////////
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace Test1
{
/// <summary>
/// Summary description for Parent.
/// </summary>
public class Parent : System.Windows.Forms.Form
{
private System.Windows.Forms.MainM
enu mainMenu1;
private System.Windows.Forms.MenuI
tem menuItem1;
private System.Windows.Forms.MenuI
tem menuItem2;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Cont
ainer components = null;
public Parent()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.mainMenu1 = new System.Windows.Forms.MainM
enu();
this.menuItem1 = new System.Windows.Forms.MenuI
tem();
this.menuItem2 = new System.Windows.Forms.MenuI
tem();
//
// mainMenu1
//
this.mainMenu1.MenuItems.A
ddRange(ne
w System.Windows.Forms.MenuI
tem[] {
this.menuItem1});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.MenuItems.A
ddRange(ne
w System.Windows.Forms.MenuI
tem[] {
this.menuItem2});
this.menuItem1.Text = "Show Dialog";
//
// menuItem2
//
this.menuItem2.Index = 0;
this.menuItem2.Text = "Show!";
this.menuItem2.Click += new System.EventHandler(this.m
enuItem2_C
lick);
//
// Parent
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.IsMdiContainer = true;
this.Menu = this.mainMenu1;
this.Name = "Parent";
this.Text = "Parent";
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Parent());
}
private void menuItem2_Click(object sender, System.EventArgs e)
{
Test1.Dialog Dialog = new Test1.Dialog();
Dialog.Show();
}
}
}
/////////////
//Dialog.cs//
/////////////
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace Test1
{
/// <summary>
/// Summary description for Dialog.
/// </summary>
public class Dialog : System.Windows.Forms.Form
{
private System.Windows.Forms.Butto
n button1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Cont
ainer components = null;
public Dialog()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Butto
n();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(104, 104);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "Show Child";
this.button1.Click += new System.EventHandler(this.b
utton1_Cli
ck);
//
// Dialog
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.AddRange(new
System.Windows.Forms.Contr
ol[] {
this.button1});
this.Name = "Dialog";
this.Text = "Dialog";
this.ResumeLayout(false);
}
#endregion
private void button1_Click(object sender, System.EventArgs e)
{
Test1.Child chform = new Test1.Child();
Test1.Parent Parent = new Test1.Parent();
chform.MdiParent = Parent;
chform.Show();
}
}
}
////////////
//Child.cs//
////////////
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace Test1
{
/// <summary>
/// Summary description for Child.
/// </summary>
public class Child : System.Windows.Forms.Form
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Cont
ainer components = null;
public Child()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Cont
ainer();
this.Size = new System.Drawing.Size(300,30
0);
this.Text = "Child";
}
#endregion
}
}
View the Solution FREE for 30 Days