У меня есть DatagridView, который должен отображать данные списка в виде строк.
private List<WadAnimCommand> _animCommands = new List<WadAnimCommand>();
Я установил источник данных следующим образом:
private void Initialize(AnimationNode animation, WadAnimCommand startupCommand, bool genBackup = false)
{
_animation = animation;
//Make a copy of the Animation's commands. we dont want to edit the Commands directly
_animCommands = animation.WadAnimation.AnimCommands.ToList();
this.gridViewCommands.CellFormatting += GridViewCommands_CellFormatting;
this.gridViewCommands.DataSource = _animCommands;
;
}
метод форматирования выглядит следующим образом:
private void GridViewCommands_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if(gridViewCommands.Columns[e.ColumnIndex].Name == "colCommands")
{
WadAnimCommand cmd = (WadAnimCommand)e.Value;
if(cmd != null) // is null
{
e.Value = cmd.ToString();
e.FormattingApplied = true;
}
}
}
Согласно моему отладчику, источник данных правильно заполнен, но DatagridView показывает указанное значение Null, в моем случае "//".
Вот вывод моего отладчика при установке источника данных: ![enter image description here](https://i.stack.imgur.com/SvYGS.jpg)
А при вызове функции CellFormatting:
![enter image description here](https://i.stack.imgur.com/ulGxm.jpg)
Я что-то забыл?
€ dit: Отладчик показывает правильные значения gridViewCommands.dataSource.