数据绑定时,DataGridView不允许添加新行 [英] DataGridView doesn't allow to add new rows when databound

查看:776
本文介绍了数据绑定时,DataGridView不允许添加新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好......

当我在Windows窗体上放置DataGridView并运行应用程序时,会显示允许添加新行的空白行。

When I place a DataGridView on a Windows form and I run the application, the blank row that allows to add a new row is shown.

当我将控件数据绑定到对象数据源并且没有检索到记录时,DataGridView不会显示空白行。它没有显示任何内容。

When I databind the control to an object datasource and no records are retrieved, DataGridView doesn't show the blank row. It shows nothing.

如何解决问题?

谢谢

Jaime

推荐答案

我认为这不是一个真正的问题。因为控件有一个数据源属性SET,因此无论返回什么值(即使没有)将被设置为无界控件,它将显示一个空行,等待输入,因为它没有数据源属性集。

its not really a problem I believe. its because the control has a datasource property SET, therefore whatever values are returned (even if nothing) will be set as with an unbounded control, it will show a blank row for you waiting for input, since it does not have a datasource property set.

你可以使用:

this.theDataGridView.AllowUserToAddRows = false;

this.theDataGridView.AllowUserToAddRows = false;

可能会阻止该行显示未绑定的数据源。

to perhaps prevent the row from being displayed if it has an unbound datasource.

有帮助吗?


这篇关于数据绑定时,DataGridView不允许添加新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆