0
我正在處理一個項目,其中我將自定義列表綁定到數據網格。我認爲我目前的應用程序可能有一些問題,所以我決定在4.0中創建一個新的示例應用程序,但同樣的問題。無法將我的列表綁定到datagridView
namespace WindowsFormsApplication1
{
public partial class Form1 : Form`
{
public Form1()
{
InitializeComponent();
}
private void populate()
{
List<BillInfoCustom> oSalesList = new List<BillInfoCustom>();
BillInfoCustom oSalesType = new BillInfoCustom() { BillId = 1, BillDate = DateTime.Now.ToLongDateString(), CashPayment = 10, CreditCardPaymet = 20, CustomerName = "asda", TotalPrice = 20.0 };
BillInfoCustom oSalesType2 = new BillInfoCustom() { BillId = 1, BillDate = DateTime.Now.ToLongDateString(), CashPayment = 10, CreditCardPaymet = 20, CustomerName = "asda", TotalPrice = 20.0 };
BillInfoCustom oSalesType3 = new BillInfoCustom() { BillId = 1, BillDate = DateTime.Now.ToLongDateString(), CashPayment = 10, CreditCardPaymet = 20, CustomerName = "asda", TotalPrice = 20.0 };
oSalesList.Add(oSalesType);
oSalesList.Add(oSalesType2);
oSalesList.Add(oSalesType3);
dataGridView1.DataSource = oSalesList;
}
private void button1_Click(object sender, EventArgs e)
{
populate();
}
}
public class BillInfoCustom
{
public int BillId;
public double TotalPrice;
public double CashPayment;
public double CreditCardPaymet;
public string CustomerName;
public string BillDate;
}
}
這裏是輸出後,我按按鈕:在性能,而不是場
它沒有,也嘗試過這一點。和我的情況是不同於你提到的問題 – DDR 2013-03-28 06:28:34