vb.net DataGridView - 如何隐藏“新”行?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3432825/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 14:59:53  来源:igfitidea点击:

DataGridView - how to hide the "new" row?

vb.netwinformsdatagridview

提问by Mawg says reinstate Monica

My DataGridView is read-only - the user cannot enter data into it, so that empty row at the end (the "new" row?) just looks ugly.

我的 DataGridView 是只读的 - 用户无法向其中输入数据,因此末尾的空行(“新”行?)看起来很难看。

How can I prevent it from displaying?

我怎样才能阻止它显示?

回答by p.campbell

On the form designer view, click the little arrow to the right on the DataGridView. Adjust the value for Enable Adding. That will remove the row at the bottom of your grid.

在表单设计器视图上,单击 DataGridView 右侧的小箭头。调整 的值Enable Adding。这将删除网格底部的行。

alt text

替代文字

Programmatically, you can adjust the AllowUserToAddRowsproperty.

以编程方式,您可以调整该AllowUserToAddRows属性。

myGrid.AllowUserToAddRows = False

回答by David Hall

The DataGridViewhas a boolean property AllowUserToAddRows. Set this to false and you should no longer see the empty row at the end of the grid.

DataGridView有一个布尔属性AllowUserToAddRows。将此设置为 false,您将不会再看到网格末尾的空行。

回答by user3892995

Just a clarification for other people who are looking at this for WPF the datagrid property has been renamed to CanUserAddRows

只是为其他正在查看 WPF 的人澄清 datagrid 属性已重命名为 CanUserAddRows