回答編集履歴

1

追記

2018/09/19 01:01

投稿

YAmaGNZ
YAmaGNZ

スコア10259

test CHANGED
@@ -1,3 +1,105 @@
1
1
  親ウインドウが子ウインドウのインスタンスを保持していると思いますので
2
2
 
3
3
  子ウインドウにpublicなメソッドを用意して呼び出せばいいのでは?
4
+
5
+
6
+
7
+ ### 追記
8
+
9
+ 下記コードで試してみました。
10
+
11
+
12
+
13
+ - 親フォーム
14
+
15
+ フォームデザイナでTextBox1つとボタン1つ、DockPanelを配置しました。
16
+
17
+ DockPanelのStyleはDockingWindowとしました。
18
+
19
+ ```C#
20
+
21
+ public partial class ParentForm : Form
22
+
23
+ {
24
+
25
+ private ChildForm childForm1;
26
+
27
+ private ChildForm childForm2;
28
+
29
+
30
+
31
+ public ParentForm()
32
+
33
+ {
34
+
35
+ InitializeComponent();
36
+
37
+
38
+
39
+ childForm1 = new ChildForm("左側");
40
+
41
+ childForm1.Show(dockPanel1,WeifenLuo.WinFormsUI.Docking.DockState.DockLeft);
42
+
43
+
44
+
45
+ childForm2 = new ChildForm("右側(自動)");
46
+
47
+ childForm2.Show(dockPanel1, WeifenLuo.WinFormsUI.Docking.DockState.DockRightAutoHide);
48
+
49
+ }
50
+
51
+
52
+
53
+ private void button1_Click(object sender, EventArgs e)
54
+
55
+ {
56
+
57
+ childForm1.ViewMessage(textBox1.Text);
58
+
59
+ }
60
+
61
+
62
+
63
+ }
64
+
65
+
66
+
67
+ ```
68
+
69
+
70
+
71
+ - 子フォーム
72
+
73
+ ```C#
74
+
75
+ public partial class ChildForm : WeifenLuo.WinFormsUI.Docking.DockContent
76
+
77
+ {
78
+
79
+ public ChildForm(string title)
80
+
81
+ {
82
+
83
+ InitializeComponent();
84
+
85
+
86
+
87
+ this.Text = title;
88
+
89
+ }
90
+
91
+
92
+
93
+ public void ViewMessage(string message)
94
+
95
+ {
96
+
97
+ MessageBox.Show(message);
98
+
99
+ }
100
+
101
+ }
102
+
103
+
104
+
105
+ ```