Привет,
Из двух потоков приходит информация и выдаётся на UI. Делаю UI update через BeginInvoke. Для этого имеется два делегата, в одном происходит добавление row.
Иногда получаю странную Exception при добавлении новой row в GataDridView:
SystemInvalidOperationException: No row can be added to a DataGridView control that does not have columns. Columns must be added fist.
Столбцы DatagridView инициализируются статически при создании контрола. Поэтому здесь проблем не должно быть.
Кусок кода где возникает Exception:
row = GetRowWithKey(sKey);
if (row == null)
{
int index = dataGridViewConfServers.Rows.Add();
if (index >= 0)
{
row = dataGridViewConfServers.Rows[index];
row.Tag = obService;
}
else
{
throw new Exception("Can't create new row.");
}
}
row.Cells[0].Value = obService.Parent.ExternLookupName == null ? obService.Name : obService.Parent.ExternLookupName;
row.Cells[1].Value = obService.EndPoint.ToString();
row.Cells[2].Value = obService.State.ToString();
Exception возникает при:
int index = dataGridViewConfServers.Rows.Add();
Где копать?