PrintDialog causes in a visual style exception Options

codeling Posts: 1089 Points: 4569
Posted: Thursday, June 7, 2018 12:08:47 PM

The following C# statement causes causes in a visual style exception thrown.

PrintDialog pd = new PrintDialog();


"Visual styles related operation resulted in an error because visuals types are currently disabled in the client area"

It is responsible for disable the visual style renderer. I don't know why he is doing that.

I have tried to reenable the visual style immediately after closing the print dialog with:


but without success.

The fact is that the printer driver changes the "VisualStyleState" value. To solve this, you can rechanged the property to the default setting directly after closing the "PrintDialog" with:

Application.VisualStyleState = VisualStyleState.ClientAndNonClientAreasEnabled;


Users browsing this topic