0

I have a DGV that has two columns where one of the columns is read only. The other column the user can makes edits in.

I have it coded with a predetermined number of rows(8). I have set the property "Enable Adding" of new rows to false. Setting this property to False makes the last row not visible.

All is good. Or is it? Meaning, if I arrow down through the rows, once my cursor reaches the last row of the DGV, a new "row" is added to the DGV. I want to prevent this occurrence.

Setting "Enable Adding" does not completely disable adding of new rows (?).

Matt Wilko
  • 26,994
  • 10
  • 93
  • 143
busarider29
  • 185
  • 5
  • 18
  • Does this help? http://stackoverflow.com/questions/22330173/editable-datagrid-canuseraddrows-true-not-working – Kevin Minehart May 10 '16 at 13:22
  • 1
    There is no such property of `Enable Adding` please use the exact property name so we all know we are talking about the same thing. Did you mean `AllowUserToAddRows` – Matt Wilko May 10 '16 at 13:25
  • Matt, I was referring to the checkbox labeled "Enable Adding" after you click on the little arrow in the upper right of the DGV in the design editor. I have that box deselected and I also have the property "AllowUserToAddRows" set to false. – busarider29 May 10 '16 at 13:54
  • "Enable Adding" is just the smart tag/control designer interface for `AllowUserToAddRows`. If that is off, the blank new row is not at the bottom. If it is adding one when you scroll, you may have code adding one. An [MCVE] snippet would help – Ňɏssa Pøngjǣrdenlarp May 10 '16 at 14:02

2 Answers2

0

There is a property on the System.Windows.Forms.DataGridView.AllowUserToAddRows, set it to false. Hope it helps.

Enable Adding property on designer

Ralph
  • 131
  • 10
0

The DataGridView height size in pixels needs to be at least 2 pixels greater than the total height of all the rows and the header row combined if you want the rows to fit perfectly in the DGV without any white space at the bottom of the DGV. Setting the heights to be equal (DGV height size = summation of all row heights + columnheader height) will not work. What happens there is what was described in the original post. You tab down through the rows and when the cursor enters the last row, white space is added at the bottom of the DGV. This looks like another row but is just white space added to the DGV.

busarider29
  • 185
  • 5
  • 18