I have this datagridview in C#. When I load the form and the data is loaded (data is loaded from SQL Server Database) in this datagridview, one of my column is not visible also the width of columns is not correct, but when I search something and that data is loaded in the datagridview then everything is perfect. I don't want the scrollbar in the datagridview.
The following images shows the difference.
One column "Description" is not shown.
How I want the datagridview to show the data
CodePudding user response:
You can use this code to change the width of the column in DatagridView:
DatagridView.Columns[your columns index].Width = your size;
You can turn off the auto-size mode with this:
DatagridView.AutoSize = false;
CodePudding user response:
I have fixed the issue by setting Autosizemode to NotSet in Layout for DataGridView columns and giving them custom width values.
When I run the application and the data is loaded in the DataGridView I set AutosizeMode for one column to Fill and everything is perfect.