vgru
vgru

Reputation: 51224

Allow DataGridView column headers to scroll away

Is it possible to make DataGridView column headers scroll out of view along with other rows when the grid is scrolled down? I.e. not to keep them visible at all times?

Is there a property in DataGridView which would allow this?

Upvotes: 1

Views: 776

Answers (1)

Grant Winney
Grant Winney

Reputation: 66449

I don't know of any design-time property you could set, but maybe you could do something like this? (Not tested, not sure how well it will perform.)

    private void dataGridView1_Scroll(object sender, ScrollEventArgs e)
    {
        if (e.ScrollOrientation == ScrollOrientation.VerticalScroll)
            dataGridView1.ColumnHeadersVisible = (e.NewValue == 0);
    }

Upvotes: 1

Related Questions