Form resolution suddenly changes after datagridview update

Viewed 134

I have this problem: my form module changes resolution unexpectedly during runtime.

I have a form module which contains a DataGridView and when I run the form everything is fine, the form is displayed correctly. However, when I drag & drop on the form, it suddenly changes resolution without my being able to find an explanation.

Form before drag & drop Form after drag & drop

The application target framework is .NET 4.5.2

I have verified that the problem occurs when calling the Update and Refresh methods on the DataGridView component, but despite having made countless attempts I do not understand what the problem is.

        this.dataGridView.BeginInvoke(new Action(() => this.dataGridView.Update()));
        this.dataGridView.BeginInvoke(new Action(() => this.dataGridView.Refresh()));

Here are the seetings of the Form and of the DataGridView component

Form layout settings DataGridView layout settings

Thanks everyone for the help

1 Answers

I found out that the issue was not in the layout/properties of the form nor in the dataGridView component settings, but it was triggered by a third party library: GemBox.Pdf which somehow was sensible to the DPI of the screen.

Putting [assembly: System.Windows.Media.DisableDpiAwareness] into the file AssemblyInfo.cs solved the issue

Many Thanks everyone for the help!!

Related