C # OpenFileDialog only shows XP style in Win7

I am working with a .NET 3.5 application that uses System.Windows.Forms.OpenFileDialog. However, no matter what I do, only the XP-Style version is displayed in the dialog that opens. I made the code as simple as possible:

OpenFileDialog openFileDialog = new OpenFileDialog() //openFileDialog.AutoUpgradeEnabled = true; //Adding this line does nothing if(DialogResult.OK == openFileDialog.ShowDialog()) { ... } 

No matter what I do, the old version of XP-Style is always displayed in the dialog box instead of the new version of Vista +. I also noticed that when I debug and look at some parameters, there is a protected member variable somewhere in the chain: SettingsSupportVistaDialog , which in this case is set to false . I am not sure if this is a problem, or where / why it can be fixed.

Does anyone have any suggestions?

Here is a screenshot of the existing dialog (XP-style) XP-Style Dialog

Here is what I want it to look like this: enter image description here

+4
source share
1 answer

I found a problem. I had to delve into the source code of .NET 3.5, but it turns out that if Application.VisualStyleState not installed in ClientAreaEnabled or ClientAndNonClientAreasEnabled , the old XP style dialog will be used.

+4
source

Source: https://habr.com/ru/post/1447063/


All Articles