50

For C# Window Form, there is a tool called DataGridView.

If we use that to display data, it shows an extra line.

If we have 3 rows of data, it shows 4 rows. the 4th row is a blank row.

I wanna know how to disable it.. or hide it?

william
  • 7,284
  • 19
  • 66
  • 106

3 Answers3

102

Do it like this:

myDataGridView1.AllowUserToAddRows = false
IordanTanev
  • 6,130
  • 5
  • 40
  • 49
6

In the DataGridView properties (small arrow at the top right corner of the control) uncheck Enable Adding, or in the Properties window at the right side of the screen set AllowUserToAddRows to False.

Raj
  • 800
  • 7
  • 8
4

From your Project [Design] view click on the DataGridView1 and from the (Properties) set it like this:

enter image description here

-Or-

Use this code:

DataGridView1.Rows.RemoveAt(DataGridView1.CurrentCell.RowIndex);
CrownFord
  • 709
  • 5
  • 15