using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
public partial class ChildForm : Form
{
public ChildForm()
{
InitializeComponent();
}
private void settoRedToolStripMenuItem_Click(object sender, EventArgs e)
{
this.BackColor = Color.Red;
}
private void settoBlueToolStripMenuItem_Click(object sender, EventArgs e)
{
this.BackColor = Color.Blue;
}
private void settoGreenToolStripMenuItem_Click(object sender, EventArgs e)
{
this.BackColor = Color.Green;
}
public void Save()
{
MessageBox.Show("I have saved my data!");
}
}
partial class ChildForm
{
private void InitializeComponent()
{
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.specialToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.settoRedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.settoBlueToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.settoGreenToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.specialToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(534, 24);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
//
// specialToolStripMenuItem
//
this.specialToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.settoRedToolStripMenuItem,
this.settoBlueToolStripMenuItem,
this.settoGreenToolStripMenuItem});
this.specialToolStripMenuItem.Name = "specialToolStripMenuItem";
this.specialToolStripMenuItem.Text = "&Special";
//
// settoRedToolStripMenuItem
//
this.settoRedToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta;
this.settoRedToolStripMenuItem.Name = "settoRedToolStripMenuItem";
this.settoRedToolStripMenuItem.Text = "Set to Red";
this.settoRedToolStripMenuItem.Click += new System.EventHandler(this.settoRedToolStripMenuItem_Click);
//
// settoBlueToolStripMenuItem
//
this.settoBlueToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta;
this.settoBlueToolStripMenuItem.Name = "settoBlueToolStripMenuItem";
this.settoBlueToolStripMenuItem.Text = "Set to Blue";
this.settoBlueToolStripMenuItem.Click += new System.EventHandler(this.settoBlueToolStripMenuItem_Click);
//
// settoGreenToolStripMenuItem
//
this.settoGreenToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta;
this.settoGreenToolStripMenuItem.Name = "settoGreenToolStripMenuItem";
this.settoGreenToolStripMenuItem.Text = "Set to Green";
this.settoGreenToolStripMenuItem.Click += new System.EventHandler(this.settoGreenToolStripMenuItem_Click);
//
// ChildForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(534, 541);
this.Controls.Add(this.menuStrip1);
this.MainMenuStrip = this.menuStrip1;
this.Name = "ChildForm";
this.Text = "ChildForm";
this.menuStrip1.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem specialToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem settoRedToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem settoBlueToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem settoGreenToolStripMenuItem;
}
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void newToolStripMenuItem_Click(object sender, EventArgs e)
{
ChildForm child = new ChildForm();
child.MdiParent = this;
child.Show();
}
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
{
ChildForm formToSave = (ChildForm)this.ActiveMdiChild;
formToSave.Save();
}
private void fileToolStripMenuItem_DropDownOpening(object sender, EventArgs e)
{
if (this.MdiChildren.Length == 0)
saveToolStripMenuItem.Enabled = false;
else
saveToolStripMenuItem.Enabled = true;
}
}
partial class Form1
{
private void InitializeComponent()
{
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.newToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fileToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(576, 24);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
//
// fileToolStripMenuItem
//
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.newToolStripMenuItem,
this.saveToolStripMenuItem,
this.toolStripSeparator1,
this.exitToolStripMenuItem});
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
this.fileToolStripMenuItem.Text = "&File";
this.fileToolStripMenuItem.DropDownOpening += new System.EventHandler(this.fileToolStripMenuItem_DropDownOpening);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
//
// newToolStripMenuItem
//
this.newToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta;
this.newToolStripMenuItem.Name = "newToolStripMenuItem";
this.newToolStripMenuItem.Text = "&New";
this.newToolStripMenuItem.Click += new System.EventHandler(this.newToolStripMenuItem_Click);
//
// saveToolStripMenuItem
//
this.saveToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta;
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
this.saveToolStripMenuItem.Text = "&Save";
this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click);
//
// exitToolStripMenuItem
//
this.exitToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta;
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
this.exitToolStripMenuItem.Text = "E&xit";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(576, 438);
this.Controls.Add(this.menuStrip1);
this.IsMdiContainer = true;
this.MainMenuStrip = this.menuStrip1;
this.Name = "Form1";
this.Text = "Form1";
this.menuStrip1.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem newToolStripMenuItem;
}
public class ChildFormBackGround
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.Run(new Form1());
}
}
|