MainMenu的Merge使用

<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 728x15, 创建于 08-4-23MSDN */ google_ad_slot = "3624277373"; google_ad_width = 728; google_ad_height = 15; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 160x600, 创建于 08-4-23MSDN */ google_ad_slot = "4367022601"; google_ad_width = 160; google_ad_height = 600; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
MainMenu Merge

windows form的程序使用菜单MainMenu是,有时需要根据操作隐藏或显示menuitem,另外窗体类和关联的菜单项事件在一个class中,结构清晰。

do like this:
class Form1: Form{    
    public Form1()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();            
            IsMdiContainer = true;
            Menu = new MainMenu();
            MenuItem File = Menu.MenuItems.Add("&File");
            File.MergeType = MenuMerge.MergeItems;
            File.MergeOrder = 0;
            MenuItem FileNew = File.MenuItems.Add("&New", new EventHandler(New_Click));
            FileNew.Shortcut = Shortcut.CtrlN;
            FileNew.MergeOrder = 10;

            
        }
        private void New_Click(Object Sender,EventArgs e)
        {
        
        }
// other codes
}
public class doc : System.Windows.Forms.Form
    {
        public doc()
        {
            Menu = new MainMenu();
            MenuItem File = Menu.MenuItems.Add("&File");
            File.MergeType = MenuMerge.MergeItems ;
            File.MergeOrder = 0;
            MenuItem Save=File.MenuItems .Add ("&Save",new EventHandler (Save_Click));
            Save.MergeType =MenuMerge.MergeItems ;
            Save.MergeOrder =9;

            MenuItem Saveas=File.MenuItems .Add ("&Save as",new EventHandler (Saveas_Click));
            Saveas.MergeType =MenuMerge.MergeItems ;
            Saveas.MergeOrder =11;
            
            MenuItem Help = Menu.MenuItems.Add("&Help");
            Help.MergeOrder = 400;    
            Help.MenuItems.Add("&About .NET Resourcer");
        }
        private void Save_Click(Object Sender,EventArgs e)
        {
        
        }
        private void Saveas_Click(Object Sender,EventArgs e)
        {
           MessageBox.Show ("Hello guys");
        }
// other code
}

11AIT52V093928.jpg
seover="window.status='正文--MainMenuMerge使用';return true">
<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 728x15, 创建于 08-4-23MSDN */ google_ad_slot = "3624277373"; google_ad_width = 728; google_ad_height = 15; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script type="text/javascript"><!-- google_ad_client = "pub-2947489232296736"; /* 160x600, 创建于 08-4-23MSDN */ google_ad_slot = "4367022601"; google_ad_width = 160; google_ad_height = 600; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
阅读更多
个人分类: .net
上一篇如何查看Oracle数据表的建表语句?
下一篇数据挖掘概述
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭