У меня проблема со следующим фрагментом кода. Когда я перехожу к отладчику, я получаю исключение, когда дело доходит до следующей строки:
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();
}
Есть предложения?