Ejemplo n.º 1
0
        //----------------------------------------------------------
        //函式名稱: SetContextMenuStrip_04
        //說明: LB_tablename右鍵選單內容
        //參數: 無
        //回傳值: 無
        //----------------------------------------------------------
        private void SetContextMenuStrip_04()
        {
            /*
             * ToolStripMenuItem tsmi_200 = new ToolStripMenuItem("複製", null, new EventHandler(tsmi_200_Click));
             * ToolStripMenuItem tsmi_201 = new ToolStripMenuItem("查詢", null, new EventHandler(tsmi_201_Click));
             * cmenustrip_04.Items.Add(tsmi_200);
             * cmenustrip_04.Items.Add(tsmi_201);
             * LB_tablename.ContextMenuStrip = cmenustrip_04;
             */
            IEnumerable <MyClass.cMenuItem> enum_MenuItem =
                from item in MenuItemNameSet
                where item.ItemID.StartsWith("tsmi_20")
                select item;

            foreach (MyClass.cMenuItem item in enum_MenuItem)
            {
                ToolStripMenuItem tsmi = new ToolStripMenuItem();

                EventHandler myEventHandler = Get_MenuItem_EventHandler(item.ItemEventHandler);

                MyClass.cContextMenu newContextMenu =
                    new MyClass.cContextMenu(tsmi, item.ItemID, item.ItemName, myEventHandler);
                newContextMenu.Init_MenuItem(0);
                cmenustrip_04.Items.Add(newContextMenu.MenuItem);
            }

            //設定右鍵選單給LB_tablename
            LB_tablename.ContextMenuStrip = cmenustrip_04;
        }
Ejemplo n.º 2
0
        //----------------------------------------------------------
        //函式名稱: SetContextMenuStrip_01
        //說明: CLB_column右鍵選單內容
        //參數: 無
        //回傳值: 無
        //----------------------------------------------------------
        private void SetContextMenuStrip_01()
        {
            /*
             * ToolStripMenuItem tsmi_50 = new ToolStripMenuItem("複製", null, new EventHandler(tsmi_50_Click));
             * cmenustrip_01.Items.Add(tsmi_50);
             * CLB_column.ContextMenuStrip = cmenustrip_01;
             */

            IEnumerable <MyClass.cMenuItem> enum_MenuItem =
                from item in MenuItemNameSet
                where item.ItemID.StartsWith("tsmi_50")
                select item;

            foreach (MyClass.cMenuItem item in enum_MenuItem)
            {
                ToolStripMenuItem tsmi = new ToolStripMenuItem();

                EventHandler myEventHandler = Get_MenuItem_EventHandler(item.ItemEventHandler);

                MyClass.cContextMenu newContextMenu =
                    new MyClass.cContextMenu(tsmi, item.ItemID, item.ItemName, myEventHandler);

                newContextMenu.Init_MenuItem(0);
                cmenustrip_01.Items.Add(newContextMenu.MenuItem);
            }

            //設定右鍵選單內容給CLB_column
            CLB_column.ContextMenuStrip = cmenustrip_01;
        }
Ejemplo n.º 3
0
        //----------------------------------------------------------
        //函式名稱: SetContextMenuStrip_02
        //說明: RichTextBox右鍵選單內容
        //參數: 無
        //回傳值: 無
        //----------------------------------------------------------
        private void SetContextMenuStrip_02()
        {
            /*
             * ToolStripMenuItem tsmi_100 = new ToolStripMenuItem("執行選取SQL", null, new EventHandler(tsmi_100_Click));
             * ToolStripMenuItem tsmi_101 = new ToolStripMenuItem("直接匯出 ...", null, new EventHandler(tsmi_101_Click));
             * ToolStripMenuItem tsmi_102 = new ToolStripMenuItem("複製", null, new EventHandler(tsmi_102_Click));
             * ToolStripMenuItem tsmi_103 = new ToolStripMenuItem("剪下", null, new EventHandler(tsmi_103_Click));
             * ToolStripMenuItem tsmi_104 = new ToolStripMenuItem("貼上", null, new EventHandler(tsmi_104_Click));
             * ToolStripMenuItem tsmi_105 = new ToolStripMenuItem("全部選取", null, new EventHandler(tsmi_105_Click));
             * ToolStripMenuItem tsmi_106 = new ToolStripMenuItem("清除全部", null, new EventHandler(tsmi_106_Click));
             * cmenustrip_02_RTB.Items.Add(tsmi_100);
             * cmenustrip_02_RTB.Items.Add(tsmi_101);
             * cmenustrip_02_RTB.Items.Add(tsmi_102);
             * cmenustrip_02_RTB.Items.Add(tsmi_103);
             * cmenustrip_02_RTB.Items.Add(tsmi_104);
             * cmenustrip_02_RTB.Items.Add(tsmi_105);
             * cmenustrip_02_RTB.Items.Add(tsmi_106);
             *
             * foreach (TabPage tp in tabControl.Controls)
             * {
             *  RichTextBox rtb = (RichTextBox)tp.Controls[0];
             *  rtb.ContextMenuStrip = cmenustrip_02_RTB; //指定RTB(RichTextBox)的右鍵選單為cmenustrip_RTB
             * }
             */

            IEnumerable <MyClass.cMenuItem> enum_MenuItem =
                from item in MenuItemNameSet
                where item.ItemID.StartsWith("tsmi_10")
                select item;

            foreach (MyClass.cMenuItem item in enum_MenuItem)
            {
                ToolStripMenuItem tsmi = new ToolStripMenuItem();

                EventHandler myEventHandler = Get_MenuItem_EventHandler(item.ItemEventHandler);

                MyClass.cContextMenu newContextMenu =
                    new MyClass.cContextMenu(tsmi, item.ItemID, item.ItemName, myEventHandler);

                newContextMenu.Init_MenuItem(0);
                cmenustrip_02_RTB.Items.Add(newContextMenu.MenuItem);
            }

            foreach (TabPage tp in tabControl.Controls)
            {
                RichTextBox rtb = (RichTextBox)tp.Controls[0];
                rtb.ContextMenuStrip = cmenustrip_02_RTB; //指定RTB(RichTextBox)的右鍵選單為cmenustrip_RTB
            }
        }
Ejemplo n.º 4
0
        //----------------------------------------------------------
        //函式名稱: SetContextMenuStrip_03
        //說明: dataGridView右鍵選單內容
        //參數: 無
        //回傳值: 無
        //----------------------------------------------------------
        private void SetContextMenuStrip_03()
        {
            /*
             * ToolStripMenuItem tsmi_ins = new ToolStripMenuItem("新增", null, new EventHandler(tsmi_ins_Click));
             * ToolStripMenuItem tsmi_del = new ToolStripMenuItem("刪除", null, new EventHandler(tsmi_del_Click));
             * ToolStripMenuItem tsmi_upd = new ToolStripMenuItem("更新", null, new EventHandler(tsmi_upd_Click));
             * cmenustrip_03.Items.Add(tsmi_ins);
             * cmenustrip_03.Items.Add(tsmi_del);
             * cmenustrip_03.Items.Add(tsmi_upd);
             *
             * foreach (TabPage tp in tabControl2.Controls)
             * {
             *  DataGridView dg = (DataGridView)tp.Controls[0];
             *  dg.ContextMenuStrip = cmenustrip_03;
             * }
             */
            IEnumerable <MyClass.cMenuItem> enum_MenuItem =
                from item in MenuItemNameSet
                where item.ItemID.Equals("tsmi_ins") || item.ItemID.Equals("tsmi_del") || item.ItemID.Equals("tsmi_upd")
                select item;

            foreach (MyClass.cMenuItem item in enum_MenuItem)
            {
                ToolStripMenuItem tsmi = new ToolStripMenuItem();

                EventHandler myEventHandler = Get_MenuItem_EventHandler(item.ItemEventHandler);

                MyClass.cContextMenu newContextMenu =
                    new MyClass.cContextMenu(tsmi, item.ItemID, item.ItemName, myEventHandler);

                newContextMenu.Init_MenuItem(0);
                cmenustrip_03.Items.Add(newContextMenu.MenuItem);
            }

            foreach (TabPage tp in tabControl2.Controls)
            {
                DataGridView dg = (DataGridView)tp.Controls[0];
                dg.ContextMenuStrip = cmenustrip_03;
            }
        }