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