How can I prevent the “random” gray row from displaying in my DGV?

I have AllowUserToAddRows set to false in my DataGridView. Yet, when I navigate to the last row via the directional arrow keys, the top row scrolls out of sight and a new gray row appears at the bottom.

How can I prevent this? I want all of my rows to be visible no matter how far up, down, to the left or right I move the cursor.

Note: Navigating through the cells horizontally doesn't cause a problem - there is no gray column added when I do that. I want the rows/vertical functionality to be the same as that.


So one approach to this would be do the following:

On the DataGridView, set the propertiesAllowUserToAddRows and AllowUserToDeleteRows to false

Also, set AutoSizeRowsMode to None

Handle the resize of the DataGridView like this:

private void dataGridView1_Resize(object sender, EventArgs e)
    var rowHeight = (dataGridView1.Height - dataGridView1.ColumnHeadersHeight) / 10;
    for (int i = 0; i < 10; ++i)
        dataGridView1.Rows[i].Height = rowHeight;

In my example, the Form1_Load event just adds some rows and then calls the DGV's resize to make everything look right initially, but you could handle this different ways. Something like:

private void Form1_Load(object sender, EventArgs e)
    for (int i = 0; i < 10; ++i)
    dataGridView1_Resize(this, EventArgs.Empty);

Need Your Help

Template specialization for an empty parameter pack

c++ templates c++11 template-specialization variadic-templates

I have a variadic template function which calls itself to determine the largest number in a list (constituted by the templatized arguments). I am trying to make a specialization for when the parame...

Django working with date

python django date

I am building a site in the new pbs bento, and am being forced to use django for this instance, which I am not familiar with. Here is what I have:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.