在委托函数里给textbox.text赋值,在界面不显示是什么原因呢,
public void showInformation(object e,EventArgs msg)
{
Components.MSPort MSPortP;
MSPortP =(Components.MSPort)e;
MessageBox.Show(MSPortP.realHum[0].ToString());
T1.Text = "55555";
// this.T1.Text=MSPortP.realHum[0].ToString();
this.Refresh();
}
------解决思路----------------------
是不是线程外调用另一个线程控件的原因,
可以试下Control.Invoke 方法
------解决思路----------------------
myString = "Step number " + i.ToString() + " executed";
Thread.Sleep(400);
myFormControl1.Invoke(myFormControl1.myDelegate,
new Object[] {myString});
------解决思路----------------------
跟踪一下看看,this.T1指向什么对象
------解决思路----------------------
试试委托修改UI界面内容吧
private delegate void InvokeTextBox(TextBox tb, String msg);
private void WriteText(TextBox tb, String msg)
{
if (tb.InvokeRequired)
{
InvokeTextBox _myInvoke = new InvokeTextBox(WriteText);
this.Invoke(_myInvoke, new object[] { tb, msg });
}
else
{
tb.Text = msg;
}
}