2013-05-12 60 views
0

請幫助我在C#中的新手我的問題是我定義我的類lacry到customerList(姓名,地址和so..on)我的問題是我有一個形式的datagridview(custDGV),並試圖在這裏LAOD到它是我的代碼如何從一個List載入數據到datagridview <>

private void listCustomer_Frm_Load(object sender, EventArgs e) 
     { 
      DataGridView custDGV = new DataGridView(); 
      customerList = CustomerDB.GetListCustomer(); 
      custDGV.DataSource = customerList; 
      cm = (CurrencyManager)custDGV.BindingContext[customerList]; 
      cm.Refresh(); 
     } 

當我運行它顯示爲空白。如果有些患者告訴我我需要做什麼

+0

看看這個,看看如何綁定到詳細的​​datagridview http://msdn.microsoft.com/en-us/library/ fbk67b6z(v = vs.90).aspx – Nomad101 2013-05-12 05:51:14

+0

customerList是一個列表對不對? – jomsk1e 2013-05-13 04:33:36

回答

0

是否有人有良好的經驗處理DataGridView我的問題是,我已加載到我的customerList當我debuged我可以看到所有的10個記錄,但是當涉及到形式加載到在DataGridView不會加載它在這裏的代碼

private void listCustomer_Frm_Load(object sender, EventArgs e) 
{ 
    DataGridView custDGV = new DataGridView(); 
    customerList = CustomerDB.GetListCustomer(); 
    custDGV.DataSource = customerList; 
    cm = (CurrencyManager)custDGV.BindingContext[customerList]; 
    cm.Refresh(); 
} 
+0

BindingSource customerBindingSource = new BindingSource(); customerList = CustomerDB.GetListCustomer(); customerBindingSource.DataSource = customerList; custDGV.DataSource = customerBindingSource; //custDGV.DataSource = typeof(customerList); //customerBindingSource.DataMember =「Customer」; // cm =(CurrencyManager)customerBindingSource.BindingContext [customerList]; //cm.Refresh(); – Salsero 2013-05-13 05:29:26

相關問題