c# - DataGridView.Rows.Insert 或 DataGridView.Rows.InsertCopy 方法不起作用
问题描述
无法使用 DataGridView.Rows.Insert 或 DataGridView.Rows.InsertCopy 方法在 DataGridView 中的特定位置插入新行。
错误消息:当控件是数据绑定时,无法以编程方式将行添加到 DataGridView 的行集合。
DataGridViewRow dgwr = new DataGridViewRow();
dgwr.CreateCells(myDataGridView);
myDataGridView.AllowUserToAddRows = true;
myDataGridView.AllowUserToDeleteRows = true;
myDataGridView.Rows.Insert(5, dgwr);
或者
myDataGridView.AllowUserToAddRows = true;
myDataGridView.AllowUserToDeleteRows = true;
myDataGridView.Rows.InsertCopy(5, 2);
解决方案
推荐阅读
- excel - VBA - 逗号/点号格式(美国 > 欧盟(德语))
- python - 安装和使用无法通过 pip 或 tarball 发行版获得的 python 库的最佳实践
- c++ - 如何忽略向量中没有第二次出现的元素
- docker - 在 docker 上运行的 jenkins 无法通过 localhost 访问
- unreal-engine4 - 在虚幻引擎 4 的编辑器小部件中获取游戏状态
- android - Android内部存储文件并发读写的安全性
- ruby-on-rails - WSL (Windows) 中的 Rails Dev 不断丢失 Ruby 版本
- python - 当没有产生该值时,有没有办法更新生成器循环条件?
- python - 由于多个用户帐户、python 版本和包管理器的干扰,python 配置存在缺陷。(未找到导入请求)
- apache-kafka - Quarkus 和 MicroProfile 是否支持 Confluent Schema Registry Avro Schema?