回答編集履歴

1

追記

2018/09/02 15:52

投稿

YAmaGNZ
YAmaGNZ

スコア10268

test CHANGED
@@ -1,3 +1,45 @@
1
1
  子のアイテムから見て、親項目を2つ持つことはできません。
2
2
 
3
3
  ですので、別のアイテムとして作成し、イベントハンドラを共通させるというやり方になります。
4
+
5
+
6
+
7
+ ```C#
8
+
9
+ ToolStripMenuItem item1 = new ToolStripMenuItem("aaa");
10
+
11
+ ToolStripMenuItem item2 = new ToolStripMenuItem("bbb");
12
+
13
+
14
+
15
+ ToolStripMenuItem item_c1 = new ToolStripMenuItem("ccc");
16
+
17
+ item_c1.Click += new System.EventHandler(C1_ToolStripMenuItem_Click);
18
+
19
+ ToolStripMenuItem item_c2 = new ToolStripMenuItem("ccc");
20
+
21
+ item_c2.Click += new System.EventHandler(C1_ToolStripMenuItem_Click);
22
+
23
+
24
+
25
+ item1.DropDownItems.Add(item_c1);
26
+
27
+ item2.DropDownItems.Add(item_c2);
28
+
29
+
30
+
31
+ ContextMenuStrip c = new ContextMenuStrip();
32
+
33
+ c.Items.Add(item1);
34
+
35
+ c.Items.Add(item2);
36
+
37
+
38
+
39
+
40
+
41
+ c.Show(button1, c.Left, c.Bottom);
42
+
43
+ ```
44
+
45
+ という感じで子のイベントハンドラに同じものを設定してやればいいかと