2010-10-26 125 views
2

我正在建立一個贏得應用程序,並在那,我有一個文本框被充滿動態,並且我有一個複選框,當我的應用程序中的所有消息框checkBox.Checked=true將彈出
(並非所有的一次,只是確認味精的我無論我編碼它,一個接一個)。Textbox.text沒有得到填充,C#

我的問題是,當checkBox被選中,我TextBox.Text是越來越充滿了數據,但是當checkBox未被選中,TextBox.text是沒有得到填充數據,奇怪的事情是,當我試圖調試它,TextBox.Text是顯示文本,但關於gui TextBox.Text沒有填寫,現在哪裏有數據?

public void Recharge() 
{ 
    txtTransactionMsgDelegate(Tm) // this is delegate function which fills the text 
           //textbox.text=tm; i tried this one too,but no use 

} 
if (Program.AutoManual == "Auto") 
{ 
    if (chkShowMsg.Checked) 
    { 
     if (returnRows < 1) 
      MessageBox.Show(Program.StatusMessage + " But Local Db Failed, NOTEDOWN IN NOTEBOOK"); 
     else 
      MessageBox.Show(Program.StatusMessage + " And Local Db update SuccessFul, RUN UPDATE RECHARGE LATER"); 
    } 
} 

委託功能:

// m using this delegate b'coz my above function i.e Recharge() is under BackGroundWorker Thread i.e BackGroundWorker_DoWork() event; 
private void txtTransactionMsgDelegate(string Text) 
{ 
    if (txtTransactionMsg.InvokeRequired) 
    { 
     txtTransactionMsg.Invoke(new Action(delegate() { txtTransactionMsgDelegate(Text); })); 
    } 
    else 
    txtTransactionMsg.Text = Text; 
} 

回答

2

要確保文本框更新在GUI上你應該叫txtTransactionMsg.Refresh();

+0

感謝名單豬頭...它的工作原理 – FosterZ 2010-10-26 09:55:21