C# WinForms BindingList & DataGridView - 不允许编辑会阻止创建新行?我该如何解决这个问题?
关于我将 DataGridView 与 BindingList 一起使用,我将禁用编辑当前行,但允许添加新行。我遇到的问题是,当我不允许编辑时,这似乎阻止了添加新行项目,因为当您将表格放入该新行的单元格时,它似乎不允许编辑???
知道如何解决这个问题吗?下面是我的代码部分:
BindingSource bs = new BindingSource();
bList = new BindingList<Customer>();
bList.AllowNew = true;
bList.AllowEdit = false;
// Fill bList with Customers
bList.Add(new Customer("Ted"));
bList.Add(new Customer("Greg"));
bList.Add(new Customer("John"));
bs.DataSource = bList;
dataGridView1.DataSource = bs;
谢谢
Regarding my use of a DataGridView with BindingList, I was to disable editing current rows, but allow adding new rows. The issue I have is that when I disallows edits, this seems to prevent one from adding a new row item, as when you table into the cell for this new row it does not seem to allow editing???
Know how to get around this? Section of my code below:
BindingSource bs = new BindingSource();
bList = new BindingList<Customer>();
bList.AllowNew = true;
bList.AllowEdit = false;
// Fill bList with Customers
bList.Add(new Customer("Ted"));
bList.Add(new Customer("Greg"));
bList.Add(new Customer("John"));
bs.DataSource = bList;
dataGridView1.DataSource = bs;
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
与其与源作斗争,不如请求 DataGridView 来主持:(
并且不要在列表上设置AllowEdit)
Rather than fight the source, perhaps ask the
DataGridView
to officiate:(and don't set
AllowEdit
on the list)