DataGridView 不显示最下面的新行:

简介:
通常  DataGridView  的最下面一行是用户新追加的行(行头显示  *  )。如果不想让用户新追加行即不想显示该新行,可以将  DataGridView  对象的  AllowUserToAddRows  属性设置为  False

[VB.NET]
设置用户不能手动给  DataGridView1  添加新行
DataGridView1.AllowUserToAddRows =  False

 

[C#]
//  设置用户不能手动给  DataGridView1  添加新行
DataGridView1.AllowUserToAddRows =  false ;

但是,可以通过程序:  DataGridViewRowCollection.Add   DataGridView  追加新行。

补足:   如果  DataGridView   DataSource  绑定的是  DataView,  还可以通过设置  DataView.AllowAdd
属性为  False  来达到同样的效果。




本文转自 qianshao 51CTO博客,原文链接:http://blog.51cto.com/qianshao/201777,如需转载请自行联系原作者

目录
相关文章
C#编程-72:dataGridView删除行
C#编程-72:dataGridView删除行
279 0
|
2月前
Datagridview 显示当前选中行
Datagridview 显示当前选中行
23 0
|
4月前
dataGrid 删除行和添加行
dataGrid 删除行和添加行
28 0
C#编程-20:DataGridView在HeaderCell中显示行号的方法
C#编程-20:DataGridView在HeaderCell中显示行号的方法
312 0
C#编程-20:DataGridView在HeaderCell中显示行号的方法
C#编程-23:删除datagridview中选中的多行
C#编程-23:删除datagridview中选中的多行
226 0
|
C#
C# DataGridView 在最左侧显示行号方法
代码: private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) { DataGridView dgv = send...
2398 0