DataGridView编辑实时生效和索引-1没有值问题

1. 问题:DataGridView单元格编辑后,只有离开焦点时,编辑的内容才会生效(在绑定的DataSource中生效)。

  使用 this.dataGridView1.CommitEdit(DataGridViewDataErrorContexts.Commit);  

2. 问题:绑定空List<T>,报错“其他信息:索引-1没有值”

    

    this.dataGridView1.DataSource = new List<T> { new T() };

  

原文地址:https://www.cnblogs.com/David-Huang/p/5970531.html