如何在一个表单中单击一个按钮并以另一种形式更新TextBox中的文本?
解决方法
如果您尝试使用WinForms,则可以在“子”表单中实现自定义事件.单击“子”表单中的按钮时,可能会触发该事件.
然后,您的“父”表单将侦听事件并处理它自己的TextBox更新.
public class ChildForm : Form
{
public delegate SomeEventHandler(object sender,EventArgs e);
public event SomeEventHandler SomeEvent;
// Your code here
}
public class ParentForm : Form
{
ChildForm child = new ChildForm();
child.someEvent += new EventHandler(this.HandleSomeEvent);
public void HandleSomeEvent(object sender,EventArgs e)
{
this.someTextBox.Text = "Whatever Text You Want...";
}
}