我創建了一個用於在數據網格中顯示Gmail對話的Windows應用程序。除Datagridview綁定正在工作外,所有項目都是。我不知道在綁定到GridView時發生了什麼..請查看我的代碼片段併爲我提供解決此問題的解決方案。在此先感謝。我的代碼如下附加...Datagridview不顯示數據
GmailItem _gItem = null;
List<GmailItem> lstMail = new List<GmailItem>();
for (int i = 0; i < mailCount; i++)
{
_gItem = new GmailItem();
_gItem = client.GetMailItem(i);
lstMail.Add(_gItem);
}
_bindingMails.DataSource = lstMail;
dgMails.DataSource = _bindingMails;
而且在設計頁面,這是對的DataGridView
this.dgMails.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgMails.Location = new System.Drawing.Point(6, 19);
this.dgMails.Name = "dgMails";
this.dgMails.Size = new System.Drawing.Size(504, 150);
this.dgMails.TabIndex = 0;
同樣的代碼,我在我們.CS
網頁添加該代碼dgMails.Dock = DockStyle.Fill;
dgMails.AutoGenerateColumns = true;
'_bindingMails;'的類型是什麼? – Rhapsody 2011-04-07 16:59:19
@Rhapsody:BindingSource – MAC 2011-04-07 17:00:59
我很抱歉提出相當於「你確定插入了嗎?」但是,你確定mailCount!= 0? – Yetti 2011-04-07 17:07:03