[Original source code] (01): Uses event-delegate to dynamically display the main and sub-forms, with different menus and toolbar. (Similar to SQL Server 2000 Enterprise Manager)

Source: Internet
Author: User

[Original source code] (01): Uses event-delegate to dynamically display the main and sub-forms, with different menus and toolbar. (Similar to SQL Server 2000 Enterprise Manager)

Comments (vulnerabilities, performance, etc.) are welcome ). In blogCommunityOtherwise, please indicate the author and source. Thank you!

1. Create the project "enterprisemanagerwindow ".

2. Add the main interface "frmmain. cs" (Windows form ).

Add the control "menustrip1" (menustrip) in "frmmain. cs ).

Set "frmmain. cs" attribute: ismdicontainer = true.

Set the attribute of "frmmain. cs": mainmenustrip = menustrip1.

Add the control "filetoolstripmenuitem" in "menustrip1" (toolstripmenuitem)
Add the control "actiontoolstripmenuitem" (toolstripmenuitem) in "menustrip1)
Add the control "viewtoolstripmenuitem" in "menustrip1" (toolstripmenuitem)
Add the control "toolstoolstripmenuitem" in "menustrip1" (toolstripmenuitem)
Add the control "windowtoolstripmenuitem" in "menustrip1" (toolstripmenuitem)
Add the control "helptoolstripmenuitem" (toolstripmenuitem) in "menustrip1)

Add the consoletoolstripmenuitem control to "windowtoolstripmenuitem" (toolstripmenuitem)
Add the designtoolstripmenuitem control to "windowtoolstripmenuitem" (toolstripmenuitem)

3. Add the sub-interface "frmconsole. cs" (Windows form ).

Add the control "toolstrip1" (toolstrip) in "frmconsole. cs ).

Add the control "forwardtoolstripbutton" (toolstripbutton) in "toolstrip1)
Add the control "backtoolstripbutton" (toolstripbutton) in "toolstrip1)

Add a delegate, event, trigger method, and a formclosed event to "frmconsole. cs ".Code.

Public   Delegate   Void Formexiteventhandler ();
Public   Event Formexiteventhandler exitevent;
Private   Void Onpost ()
{
If ( This . Exitevent ! =   Null )
{
This. Exitevent ();
}
}  
Private   Void Frmconsole_formclosed ( Object Sender, formclosedeventargs E)
{
This. Onpost ();
}

 

4. Add the sub-interface "frmdesign. cs" (Windows form ).

Add the control "toolstrip1" (toolstrip) in "frmdesign. cs ).

Add the control "saverelstripbutton" (toolstripbutton) in "toolstrip1)
Add the butetoolstripbutton (toolstripbutton) control to "toolstrip1)
Add the control "setprimarykeytoolstripbutton" (toolstripbutton) in "toolstrip1)

Add the delegate, event, trigger method, and formclosed Event code in "frmconsole. cs.

Public   Delegate   Void Formexiteventhandler ();
Public   Event Formexiteventhandler exitevent;
Private   Void Onpost ()
{
If ( This . Exitevent ! =   Null )
{
This. Exitevent ();
}
}  
Private   Void Frmdesign_formclosed ( Object Sender, formclosedeventargs E)
{
This. Onpost ();
}

5. Add two methods and two events to the main interface "frmmain. cs.

  Private   Void Leletoolstripmenuitem_click ( Object Sender, eventargs E)
{
Frmconsole OBJ =   New Frmconsole ();
OBJ. exitevent + =   New Frmconsole. formiteventhandler (consoleexit );
OBJ. maximizebox =   True ;
OBJ. minimizebox =   True ;
OBJ. showintaskbar =   False ;
OBJ. startposition = Formstartposition. Manual;
OBJ. windowstate = Formwindowstate. maximized;
OBJ. mdiparent =   This ;
OBJ. Show ();
}

Private   Void Consoleexit ()
{
This . Filetoolstripmenuitem. Visible =   True ;
This . Actiontoolstripmenuitem. Visible =   True ;
This . Viewtoolstripmenuitem. Visible =   True ;
This . Toolstoolstripmenuitem. Visible =   True ;
This . Windowtoolstripmenuitem. Visible =   True ;
This . Helptoolstripmenuitem. Visible =   True ;
}

Private   Void Designtoolstripmenuitem_click ( Object Sender, eventargs E)
{
This . Filetoolstripmenuitem. Visible =   True ;
This . Actiontoolstripmenuitem. Visible =   False ;
This . Viewtoolstripmenuitem. Visible =   False ;
This . Toolstoolstripmenuitem. Visible =   False ;
This . Windowtoolstripmenuitem. Visible =   True ;
This . Helptoolstripmenuitem. Visible =   True ;

Frmdesign OBJ =   New Frmdesign ();
OBJ. exitevent + =   New Frmdesign. formiteventhandler (designexit );
OBJ. maximizebox =   True ;
OBJ. minimizebox =   True ;
OBJ. showintaskbar =   False ;
OBJ. startposition = Formstartposition. Manual;
OBJ. windowstate = Formwindowstate. maximized;
OBJ. mdiparent =   This ;
OBJ. Show ();
}

Private   Void Designexit ()
{
This . Filetoolstripmenuitem. Visible =   True ;
This . Actiontoolstripmenuitem. Visible =   True ;
This . Viewtoolstripmenuitem. Visible =   True ;
This . Toolstoolstripmenuitem. Visible =   True ;
This . Windowtoolstripmenuitem. Visible =   True ;
This . Helptoolstripmenuitem. Visible =   True ;
}

6. AttachmentSource code: Http://files.cnblogs.com/ClarkChan/EnterpriseManagerWindow_060920.rar

Note! Reposted outside the blog community, which must be noted:
By Clark Chan
And Source: http://clarkchan.cnblogs.com/
Otherwise, reprint is declined!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.