动网论坛,站长建站首选,国内使用量最多的论坛软件 动网论坛官方技术讨论区 站长工具 申请属于您自己的免费论坛
首页 | 新闻资讯 | 网站运营 | 网络编程 | 数据库 | 服务器 | 网页设计 | 图像媒体 | 网络应用 | 搜索优化 | 资源下载 | 动网主机 | DVBOX
    本站内  互联网 ASP论坛  ASP.Net论坛  PHP论坛
   .Net → 阅读文章

 一个多文档界面的应用程序

作者来源: 
阅读 3476 人次 , 2000-12-5 

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()

  

 
 收藏本文  打印本文  论坛讨论  关闭窗口
· 上一篇:asp+ 制作图形
· 下一篇:asp+中的hash表操作 
· Asp.net中用核选框显示数据的方法及ButtonColumn的使用方法
· XCodeFactory 强化静态检查!
· .NET体系中的源程序安全问题(3)
· ASP.NET实现网络空间管理
· C#中的函数重载


关于本站 | 联系我们 | 业务合作 | 客户案例 | 诚聘英才 | 广告合作 | 收藏本站
海口动网先锋网络科技有限公司版权所有
Copyright © 2000 - 2006 Cndw.Com
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077