从 Form1 到 Form2 中的表单名称输出的 C# TextBox 输入?
C# TextBox Input from Form1 to Form Name Output in Form2?
我需要有关将文本框的输入作为 FormName(FormText) 转换为另一个表单的代码的帮助。请帮助
如前所述,此站点上有很多示例,这里是一个。
using System;
using System.Windows.Forms;
namespace PassingDataBetweenForms
{
public partial class Form2 : Form
{
private readonly string _input;
public Form2()
{
InitializeComponent();
}
public Form2(string input)
{
InitializeComponent();
_input = input;
Shown += OnShown;
}
private void OnShown(object sender, EventArgs e)
{
textBox1.Text = _input;
}
}
}
表格 1
private void button1_Click(object sender, EventArgs e)
{
var f = new Form2(textBox1.Text);
f.ShowDialog();
}
我需要有关将文本框的输入作为 FormName(FormText) 转换为另一个表单的代码的帮助。请帮助
如前所述,此站点上有很多示例,这里是一个。
using System;
using System.Windows.Forms;
namespace PassingDataBetweenForms
{
public partial class Form2 : Form
{
private readonly string _input;
public Form2()
{
InitializeComponent();
}
public Form2(string input)
{
InitializeComponent();
_input = input;
Shown += OnShown;
}
private void OnShown(object sender, EventArgs e)
{
textBox1.Text = _input;
}
}
}
表格 1
private void button1_Click(object sender, EventArgs e)
{
var f = new Form2(textBox1.Text);
f.ShowDialog();
}