2009-10-07 69 views
0

我在Form_Load事件期間填充的Windows窗體上有一個ListBox,就像這樣。如何強制ListBox重新加載WinForm中的數據

 private void Form1_Load(object sender, EventArgs e) 
    { 
     SA.Business.ComputerList computerList; 
     computerList = SA.Business.Business.GetComputerList(); 

     this.lbComputers.DataSource = computerList; 
     this.lbComputers.DisplayMember = "Name"; 
    } 

的GetComputerList返回從的BindingList <>

繼承我有表單上的按鈕,單擊時更新是用於COMPUTERLIST對象中的數據的源表中的一個對象COMPUTERLIST。

完成更新後,我只是想強制ListBox使用來自數據庫的新數據進行自我更新。

我該怎麼做?

回答

2

摘要您的代碼加載到一個單獨的函數,然後調用該函數從你的Form_Load也從按鈕的Click事件。

0

這應該工作..

// after the code to update the source 
Form1_Load(null, null); 
相關問題