web analytics

PrintDialog causes in a visual style exception

Options

codeling 1595 - 6639
@2018-06-07 12:08:47

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

PrintDialog pd = new PrintDialog();

pd.ShowDialog();

"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:

Application.EnableVisualStyles();

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;

 

Comments

You must Sign In to comment on this topic.


© 2024 Digcode.com