DataGrid的數據綁定錯誤DataGrid的數據綁定的WinForms
class Test1
{
public DataTable table1 = new DataTable();
public BindingSource sr = new BindingSource();
}
class Test2
{
Test1 ta =new Test1();
DataTable table1 = new DataTable();
table1.Columns.Add("Dosage", typeof(int));
table1.Columns.Add("Drug", typeof(string));
table1.Columns.Add("Patient", typeof(string));
table1.Columns.Add("Date", typeof(DateTime));
table1.Rows.Add(25, "Indocin", "David", DateTime.Now);
table1.Rows.Add(50, "Enebrel", "Sam", DateTime.Now);
table1.Rows.Add(10, "Hydralazine", "Christoff", DateTime.Now);
table1.Rows.Add(21, "Combivent", "Janet", DateTime.Now);
table1.Rows.Add(100, "Dilantin", "Melanie", DateTime.Now);
ta.table1 = table1 ;
datagridview dgv = new datagridview();
dgv.AutoGenerateColumns = true ;
dgv.DataBindings.Add("DataSource",ta,"table1");
}
上面的代碼給我「不能結合於DataSource.Parameter名稱的屬性或列表1:數據成員。」 。我在這裏犯了什麼錯誤,我沒有得到它。可以幫我嗎?
__不要調用一個'DataGridView''GridView'或'DataGrid',反之亦然!這是錯誤的和混亂的,因爲這些是不同的控制。總是用__right__的名字打電話給他們! – TaW