|
|
|
|
|
|
Author Rank:
|
|
Technologies:
Windows Forms,Visual C# .NET
|
|
Total downloads :
|
|
|
Total page views :
|
105988
|
|
Rating :
|
|
3/5
|
|
This article has been rated :
|
2 times
|
|
|
Similar ArticlesMost ReadTop RatedLatest
|
|
Related EbooksTop Videos
|
|
|
Description
|
|
The Complete Visual C# Programmer's Guide, written by the authors of C# Corner, covers most of the major components that make up C# and the .NETenvironment including Windows Forms, ADO.NET, GDI+, Web Services, and Security. The book is geared toward the beginner to intermediate programmers.
|
|
|
|
|
|
|
|
|
|
|
|
|
Introduction
In this article, I will explain basics of Multiple Document Interface (MDI) applications. MDI applications let you to show multiple documents at the same time, with every document displayed in its individual window.
Creating MDI Parent Forms
The base of a Multiple Document Interface (MDI) is the MDI parent form. This is the form that holds the MDI child windows, which are all the "sub-windows" in which the client work together with the MDI application.
To Create MDI Parent Forms:
Create a new form and add the code.
this.IsMDIContainer = true;
This assign the form as an MDI container for child windows. Creating MDI Child Forms
An vital constituent of Multiple Document Interface (MDI) Applications is the MDI child forms, as these are the main windows for client interaction.
To Create MDI Child Forms:
Form frmchild=new Form(); frmchild.MDIParent=this; frmchild.Show();
Determining the Active MDI Child:
In a number of circumstance, we desire to give a command that operates on the control with the focus on the at present active child form.
For the reason that an application can have many instances of the same child form, the process wants to be acquainted with which form to use. To specify this, use the ActiveForm property of an MDI Form, which returns the child form that has the focus.
In any case one MDI child form must be loaded and visible when you access the ActiveForm property, or an error is returned.
Arranging Child Forms:
Frequently, applications will have menu commands for actions such as Tile, Cascade, and Arrange, with concerning to the open MDI child forms. One can use the LayoutMDI method with the MDILayout enumeration to rearrange the child forms in an MDI parent form.
The MDILayout enumeration can be set to four different values, which will display child forms as cascading, as horizontally or vertically. Often, these methods are used as the event handlers called by a menu item's Click event. In this way, a menu item with the text "Cascade Windows" can have the desired effect on the MDI child windows.
In the example below, the event handler for the Click event for the Cascade menu item sets the MDILayout enumeration to Cascade for the child windows of the MDI Parent form.
Example:
using System; using System.ComponentModel; using System.WinForms; using System.Drawing; public class MDI :Form { private MainMenu mainMenu; private int Count=0; public MDI() { this.IsMDIContainer=true; this.Text="MDI Demo"; mainMenu = new MainMenu(); MenuItem File = mainMenu.MenuItems.Add("&File"); File.MenuItems.Add(new MenuItem("&New",new EventHandler this.FileNew_clicked),Shortcut.CtrlN)); File.MenuItems.Add(new MenuItem("&Active Child",new EventHandler this.FindActive_clicked),Shortcut.CtrlA)); File.MenuItems.Add(new MenuItem("-")); File.MenuItems.Add(new MenuItem("&Exit",new EventHandler this.FileExit_clicked),Shortcut.CtrlX)); MenuItem Arrange = mainMenu.MenuItems.Add("&Arrange"); Arrange.MenuItems.Add(new MenuItem("&Cascade",new EventHandler this.Cascade_clicked),Shortcut.F1)); Arrange.MenuItems.Add(new MenuItem("&Horizontal",new EventHandler this.Horizontal_clicked),Shortcut.F2)); Arrange.MenuItems.Add(new MenuItem("&Vertical",new EventHandler this.Vertical_clicked),Shortcut.F3)); this.Menu=mainMenu; mainMenu.GetForm().BackColor = Color.Indigo ; } private void FileExit_clicked(object sender, EventArgs e) { this.Close(); } private void FindActive_clicked(object sender, EventArgs e) { MessageBox.Show(this.ActiveMDIChild.Text,"MDI FORM",MessageBox.IconInformation); } private void FileNew_clicked(object sender, EventArgs e) { Form frmchild=new Form(); frmchild.MDIParent=this; frmchild.Show(); frmchild.Text="Child Form" + Count.ToString(); Count++; } private void pop_Clicked(object sender, EventArgs e) { MessageBox.Show("Popupmenu","MENU_CREATION",MessageBox.IconInformation); } private void Cascade_clicked(object sender, EventArgs e) { this.LayoutMDI(MDILayout.Cascade ); } private void Horizontal_clicked(object sender, EventArgs e) { this.LayoutMDI(MDILayout.TileHorizontal); } private void Vertical_clicked(object sender, EventArgs e) { this.LayoutMDI(MDILayout.TileVertical); } public static void Main(string[] args) { Application.Run(new MDI()); } }
Output:

|
|
|
Login
to add your contents and source code to this article
|
|
|
|
|
|
|
|
|
|
|
|
G Gnana Arun Ganesh
G.GNANA ARUN GANESH, an ECE graduate (1997-2001) seeking a profession in either Software or Hardware Company. During Campus interview selected as a Software Engineer at GREEN MICRO SYSTEMS Chennai, a German collaboration company. Due to down stream in software market they have cancelled the offer. His skills includes VB, COM/DCOM, ASP, VB.NET, C# and Embedded systems. He is also a writer of numerous articles for many technical Web sites.
|
|
|
|
|
|
|
|
|
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional
consulting company, our consultants are well-known experts in .NET and many of them
are MVPs, authors, and trainers. We specialize in Microsoft .NET development and
utilize Agile Development and Extreme Programming practices to provide fast pace
quick turnaround results. Our software development model is a mix of Agile Development,
traditional SDLC, and Waterfall models.
|
|
Click here to learn more about C# Consulting. |
|
|
|
|
|
|
|
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon.
Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees.
As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
|
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
|
Go.NET
Build custom interactive diagrams, network, workflow editors, flowcharts, or software design tools. Includes many predefined kinds of nodes, links, and basic shapes. Supports layers, scrolling, zooming, selection, drag-and-drop, clipboard, in-place editing, tooltips, grids, printing, overview window, palette. 100% implemented in C# as a managed .NET Control. Document/View/Tool architecture with many properties&events. Optional automatic layout.
|
Dundas Software
Dundas Chart for .NET is the most advanced .NET charting package available today. With an extremely complete feature set, elegant architecture and easy implementation, Dundas Chart can quickly add advanced Charting functionality to enhance and transform ASP.NET and Windows Forms applications. Whether you are implementing charting into internal projects, or building applications for clients, Dundas Chart offers advanced technology and advanced results to get the most out of data.
|
Clickatell's SMS Gateway
Clickatell's Developer Solutions allow you to SMS enable any website or
application via a range of API's. Learn More about our API connections.
|
Microsoft Visual Studio 2010
Microsoft Visual Studio 2010 offers more to developers than any other
Visual Studio release. Work more productively and collaboratively-with
greater control over your work at every step. The Beta 2 can give you a
head start on achieving efficiency.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|