Pages

Tuesday, February 15, 2011

15/02 Multi Document interface:


Date 15-2-11 Tuesday

- Add a timer control and folder browser dialog to the form.

** Text con not be displayed

** Image con not be displayed


Multi Document interface: - While designing an application with multiple forms init, we are setting the startup form under the program class, but as we don’t provide source code to client, When we develop a application, he doesn’t have chance to edit the class program and specify his startup Form. In that case we use Mdi Approach.

- In this approach we will be having only one form as a startup form, so client doesn’t required to change it each time. Rest of the form in application will be under the control of Main Form or start up Form.

- Here we will be having two parts:
                        - MDI Parent
                        - MDI Child

- The form which is going to be the startup form is MDI parent and to make it as Mdi parent we need to set the IsMdiProperty of form as true.

Note – An application can have only one MdiParent, all the other forms should be child of parent, which comes and sits under parent;

Eg. Visual Studio is an MdiParent which launches all the remaining form under it as Childs.

- To launch a form as child of parent, create object of form class we want to launch, set its MdiParent property with parent forms reference and then call show method.

Layout: - When we have more than one child form to be launched under parent the way how child form gets arranged in parent can be set with a layout, which has 4 options like:
        i.              
           Cascade (D): - child forms are arranged one on the top of the other
      ii.            Tile Vertical: - child forms are arranged one beside the other
    iii.            Tile Horizontal: - child forms are arranged one blow the other
     iv.            ArrangeIcons: - all child icone are arranged with in the parent.

 Way to define a project with one MdiParent and its child: -

- Take a new form on the project and sets its IsMdiContainer property as true, so that it becomes as MdiParent and also set the windowstate property as maximize, so that the form gets launched to the full size of the screen.
- Place a menu strip control on a form and add two menus on it.
            1. Forms,
            2. Arrange

- Under Form menu add separator menu item for each form we want to launch
E.g. Form1, Form2, Form3 etc.

- Under Arrange menu add the menu items – ArrangeIcons, Cascade, vertical and Horizontal.

- Now write the following code:

Under Each Forms Menu Item:
Form1 f = new Form1();
f.MdiParent = this;
f.Show();


Under arrange icons menu Strip:
this.LayoutMdi(MdiLayout.ArrangeIcons);

Under Cascade menu Strip:
this.LayoutMdi(MdiLayout.Casecade);

Under Vertical menu Strip:
this.LayoutMdi(MdiLayout.TileVertical);

Under Horizontal menu Strip:
this.LayoutMdi(MdiLayout.TileHorizontal);



0 comments:

Post a Comment