中国IT动力,最新最全的IT技术教程
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 在线API文档
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 硬件维护 | 未整理篇 | 站长教程
ASP JS PHP工程 ASP.NET 网站建设 UML J2EESUN .NET VC VB VFP 网络维护 数据库 DB2 SQL2000 Oracle Mysql
服务器 Win2000 Office C DreamWeaver FireWorks Flash PhotoShop 上网宝典 CorelDraw 协议大全 网络安全 微软认证
硬件维护  CPU  主板  硬盘  内存  显卡  显示器  键盘鼠标  声卡音箱  打印机  机箱电源  BIOS  网卡  C#  Java  Delphi  vs.net2005
  当前位置:> 程序开发 > Web开发 > .NET > ASP.NET
一个多文档界面的应用程序
作者:未知 时间:2006-07-28 12:04 出处:不详 责编:月夜寒箫
              摘要:一个多文档界面的应用程序
namespace Microsoft.Samples.WinForms.Cs.MDI {
using System;
using System.ComponentModel;
using System.Drawing;
using System.WinForms;

 

public class MainForm : System.WinForms.Form {
private System.ComponentModel.Container components;
private System.WinForms.MainMenu mainMenu;
private System.WinForms.StatusBar statusBar1;

private int windowCount = 0 ;

public MainForm() {

// Required by the Windows Forms Designer
InitializeComponent();

// TODO: Add any constructor code after InitializeComponent call

//Setup MDI stuff
this.IsMDIContainer = true;
this.MDIChildActivate += new EventHandler(this.MDIChildActivated);

//Add File Menu
MenuItem miFile = mainMenu.MenuItems.Add("&File");
miFile.MergeOrder=0;
miFile.MergeType = MenuMerge.MergeItems;

MenuItem miAddDoc = new MenuItem("&Add Document", new EventHandler(this.FileAdd_Clicked), Shortcut.CtrlA);
miAddDoc.MergeOrder=100;

MenuItem miExit = new MenuItem("E&xit", new EventHandler(this.FileExit_Clicked), Shortcut.CtrlX);
miExit.MergeOrder=110;

miFile.MenuItems.Add(miAddDoc);
miFile.MenuItems.Add("-"); // Gives us a seperator
miFile.MenuItems.Add(miExit);

//Add Window Menu
MenuItem miWindow = mainMenu.MenuItems.Add("&Window");
miWindow.MergeOrder = 10;
miWindow.MenuItems.Add("&Cascade", new EventHandler(this.WindowCascade_Clicked));
miWindow.MenuItems.Add("Tile &Horizontal", new EventHandler(this.WindowTileH_Clicked));
miWindow.MenuItems.Add("Tile &Vertical", new EventHandler(this.WindowTileV_Clicked));
miWindow.MDIList = true ; //Adds the MDI Window List to the bottom of the menu

AddDocument(); //Add an initial doc
}


//Add a document
private void AddDocument() {
windowCount++ ;
Document doc = new Document("Document " + windowCount);
doc.MDIParent = this;
doc.Show();
}


//File->Add Menu item handler
protected void FileAdd_Clicked(object sender, System.EventArgs e) {
AddDocument() ;
}


//File->Exit Menu item handler
protected void FileExit_Clicked(object sender, System.EventArgs e) {
this.Close();
}


//One of the MDI Child windows has been activated
protected void MDIChildActivated(object sender, System.EventArgs e) {
if (null == this.ActiveMDIChild) {
statusBar1.Text = "";
} else {
statusBar1.Text = this.ActiveMDIChild.Text;
}
}

//Window->Cascade Menu item handler
protected void WindowCascade_Clicked(object sender, System.EventArgs e) {
this.LayoutMDI(MDILayout.Cascade);
}


//Window->Tile Horizontally Menu item handler
protected void WindowTileH_Clicked(object sender, System.EventArgs e) {
this.LayoutMDI(MDILayout.TileHorizontal);
}


//Window->Tile Vertically Menu item handler
protected void WindowTileV_Clicked(object sender, System.EventArgs e) {
this.LayoutMDI(MDILayout.TileVertical);
}


public override void Dispose() {
base.Dispose();
components.Dispose();
}

protected void InitializeComponent() {

this.components = new System.ComponentModel.Container();
this.mainMenu = new System.WinForms.MainMenu();
this.statusBar1 = new System.WinForms.StatusBar();

this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.Text = "MDI Example";
this.Menu = mainMenu;
this.ClientSize = new System.Drawing.Size(450, 200);

statusBar1.BackColor = System.Drawing.SystemColors.Control;
statusBar1.Size = new System.Drawing.Size(496, 20);
statusBar1.TabIndex = 1;
statusBar1.Text = "";
statusBar1.Location = new System.Drawing.Point(0, 273);

this.Controls.Add(statusBar1);
}


public static void Main(string[] args) {
Application.Run(new MainForm());
}

}
}


作者:jspfuns

关闭本页
 
首页 | 投资与合作 | 服务条款 | 隐私政策 | 收藏本站 | 设为首页 | 新用户注册 | 免责声明 | 使用帮助
Copyright ©2005-2008 chinaitpower.com All rights reserved. www.chinaitpower.com 版权所有