如何禁用在DataGridView中创建新行? [英] How to disable creation of new rows in a DataGridView?

查看:100
本文介绍了如何禁用在DataGridView中创建新行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是有关用C#编写的.NET Windows窗体应用程序的。我有一个 DataGridView 连接到数据库。它显示了选定表的内容。

This is about a .NET Windows Forms application written in C#. I have a DataGridView which is connected to a database. It displays the contents of a selected table.

现在,如果该表中有4行,它将显示4行。之后,我可以在datagrid视图中输入第5 th 行。应该避免。现在,我必须禁用创建新行。我该怎么办?

Now if there are 4 rows in that table, it will display 4 rows. After this I am able to enter the 5th row in the datagrid view. It should be avoided. Now I have to disable creation of a new row. How can I do it?

推荐答案

只需设置 DataGridView.AllowUserToAddRows 属性设为 false

这篇关于如何禁用在DataGridView中创建新行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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