0

I have a datagridview in windows form application. I have some columns to it as seen below. I set width of each column to fit exactly the data and column header. The size of the gridview at design time is 833, 342.

1- https://i.stack.imgur.com/6itRA.png

2- https://i.stack.imgur.com/PcVQb.png

3- https://i.stack.imgur.com/uTYT1.png

The problem is when I run the program, the gridview width is set to 602 and a horizontal scrollbar appears. Why is this happening although I didn't change the datagridview's AutoSizeColumnsMode ( set to none by default)

4- https://i.stack.imgur.com/PWZFR.png

Thanks

  • Your application is not DpiAware. Start from here: [How to configure an app to run correctly on a machine with a high DPI setting (e.g. 150%)?](https://stackoverflow.com/q/13228185/7444103), read on and enahance with: [High DPI support in Windows Forms](https://learn.microsoft.com/en-us/dotnet/desktop/winforms/high-dpi-support-in-windows-forms) -- If you have built a .Net 5 Project, add this information the question's body and tag it accordingly. – Jimi Sep 08 '21 at 21:25
  • have you thought about using containers and the dock or anchor properties? – henoc salinas Sep 08 '21 at 22:23

0 Answers0