Saania
Saania

Reputation: 625

C# Windows Form DataGridView: Horizontal Scroll is not shown

I have a weird yet simple problem: the horizontal scroll bars in DataGridView is not being shown (I use C#, Visual STudio 2010).

I have tried several permutations and combinations of the dataGridView properties but all in vain. The Vertical scrollbar appears when the number of rows is more than 6, this is good.

I have made Layout > ScrollBars > Both.

Here are the properties:

enter image description here

Apart from the ones mentioned above, in my code, the only property I change is:

dataGridView1.Columns[0].Width = 200;

This is how the resulting Grid View looks like after running the code. Where am I going wrong?

enter image description here

Upvotes: 0

Views: 1480

Answers (1)

Bioukh
Bioukh

Reputation: 1968

You must change the AutoSizeColumnsMode of your DataGridView. Currently, it is set to Fill so the colums are resized to fit the available place.

Here is the documentation about the available modes : https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.datagridviewautosizecolumnsmode

Upvotes: 3

Related Questions