频道直达 - 学院 - 下载 - 交易 - 特效 - 字库 - 手册 -排名-工具- 繁體
网页教学网站开发 设为首页
加入收藏
联系我们
建站搜索: 常用广告代码   用户注册 | 用户登陆
您当前的位置:中国建站之家 -> 网站开发设计技术教程 -> Asp.Net教程 -> 一个多文档界面的应用程序

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

作者:未知  来源:转载  发布时间:2005-7-20 10:04:45  发布人:acx

减小字体 增大字体

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


将本文收藏到QQ书签与更多好友分享
[打 印]
[] [返回上一页] [收 藏]
上一篇文章:asp+中的hash表操作
下一篇文章:asp+ 制作图形
∷相关文章评论∷    (评论内容只代表网友观点,与本站立场无关!) [更多评论...]
精彩推荐
热门文章
· 注册码大全二
· 注册码大全四
· 注册码大全一
· 要10G免费网络硬盘的请进..
· 通过google 赶快来赚美金..
· 注册码大全十
· 头像-qq头像(qq新头像)4..
· 让你轻松架设FTP服务器1..
· 注册码大全三
· 梦幻背景图片7
· 卡通动物图片6
· 网页制作素材-按钮素材2..
· 让你轻松架设FTP服务器5..
· 风景图片8
· 注册码大全九
· 让你轻松架设FTP服务器2..
关注此文读者还看过
· 百度:闪电裁员为保护知..
· 10网络作家遭“批判” 安..
· Flash制作电子日历时钟(..
· 避免OOP的形式,POP的思想..
· Photoshop 制作水晶按钮..
· 草根网站比门户网站更有..
· 用ASP.Net(C#)连接Oracl..
· asp实现在web中显示电子..
· asp动态include文件
· 没有定义变量的问题
· 一个通用数据库显示程序..
· 用PHP发送MIME邮件(三)..
· 使用MS SQL7的LINKED SE..
· Photoshop精彩实例:西域..
· 由EnterpriseDB论数据库..
· DW MX 2004的Flash动画元..
相关文章
· 探讨SQL语句技巧 优化DB2应..
· 用SQL Server Compact Edit..
· 用 PHP V5 开发多任务应用程..
· IIS6.0应用程序池的问题
· 在Java应用程序中使用JNI来..
· 构建一个简单的Silve..
· J2EE实用技巧:提升JSP应用..
· NET应用程序开发标准化
· AJAX开发智能Web应用程序
· 使用Eclipse Callist..
· 测试 Apache Web 和 PHP 应..
· 提升JSP应用程序的七大绝招..
· ASP、VB和XML建互联网应用程..
· ASP、VB和XML建互联网应用程..
· ASP、VB和XML建互联网应用程..
· PHP应用程序加速探索之简介..
关于本站 - 网站帮助 - 广告合作 - 下载声明 - 友情连接 - 网站地图 - 人才招聘
网站合作、内容监督、商务咨询:QQ: 9576619
Copyright ? 2005--2008 中国建站之家版权所有
粤ICP备05092265号