文本框中的值未在 winform 中显示

value in textbox not showing in winform

我正在将值从方法传递到表单构造函数和文本框,但它没有显示在文本框中。请帮忙

myhub.cs

public void sendtoserver(string msg)
{
   Clients.Caller.stos(msg);
   Form1 frm = new Form1(msg);
}


public Form1(string msg)
{
   InitializeComponent();
   textBox1.Text = msg;
}

您必须将表格显示给。

Form1 frm = new Form1(msg);
frm.Show();

无需为 Form1 创建实例,因为您已经在表单上,​​只需将 msg 分配给 textBox1

public void sendtoserver(string msg)
{
   Clients.Caller.stos(msg);
   textBox1.Text = msg;
}