これはあなたのForm1
に置くためのコードです:あなたForm2
で、今
this.hide();
List<string> results = new List<string>(); // List of all the returned results
for (int i = 0; i < 5; i++)
{
form2 obj_form2 = new form2();
obj_form2.ShowDialog();
results.Add(obj_form2.textBox.Text);
}
this.Show();
MessageBox.Show(string.Join("\n", results)); // Show all the results
、あなたが書いているテキストボックスを見つけます戻り値それを選択し、そのプロパティを見てください。プロパティModifiers
を見つけ、public
に設定します。
このコードは機能するはずです。私はこれが役立つことを願っています
あなたはまたForm2
にこの機能を追加することができます
EDIT:この
this.hide();
List<string> results = new List<string>(); // List of all the returned results
for (int i = 0; i < 5; i++)
results.Add(form2.GetInput());
this.Show();
MessageBox.Show(string.Join("\n", results)); // Show all the results
に前述のコードを
public static string GetInput()
{
form2 obj_form2 = new form2();
obj_form2.ShowDialog();
return obj_form2.textBox.Text;
}
を、変更はまだ前に述べたModifiers
プロパティを変更してください
コードを書式設定してください。 –