10
我遇到以下一段代碼有問題。當我去通過與調試我得到一個異常,當涉及到以下行:無法添加列,因爲它的CellType屬性爲空例外
dgvCalls.Columns.Insert(1, msisnnColumn);
我得到一個異常:不能添加
列,因爲它 CellType屬性爲null。
奇怪的是,我創建了一些其他DataGridViews相同的過程,它工作正常。
if (!(dgvCalls.Columns.Contains("DirectionImage")))
{
directionIconColumn = new DataGridViewImageColumn();
directionIconColumn.Name = "DirectionImage";
directionIconColumn.HeaderText = "";
dgvCalls.Columns.Insert(0, directionIconColumn);
directionIconColumn.CellTemplate = new DataGridViewImageCell();
}
if (!(dgvCalls.Columns.Contains("msisndColumn")))
{
msisnnColumn = new DataGridViewColumn();
msisnnColumn.Name = "msisndColumn";
msisnnColumn.HeaderText = "Klic";
dgvCalls.Columns.Insert(1, msisnnColumn);
msisnnColumn.CellTemplate = new DataGridViewTextBoxCell();
}
有什麼建議嗎?
您可以通過突出顯示代碼並單擊編輯textarea上方的小0101010圖標,以易於閱讀的格式顯示代碼。 – DOK 2008-11-06 16:40:11