Reputation: 625
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:
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?
Upvotes: 0
Views: 1480
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