Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable creation of new rows in a 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.

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?

like image 832
saeed Avatar asked Apr 19 '10 08:04

saeed


2 Answers

Simply set the DataGridView.AllowUserToAddRows property to false.

like image 138
stakx - no longer contributing Avatar answered Oct 01 '22 22:10

stakx - no longer contributing


Set

dataGrid.AllowUserToAddRows = false
like image 45
Axarydax Avatar answered Oct 01 '22 21:10

Axarydax