Windows Forms/DatagridView Screen Flickering
Has anyone experienced a case where a .Net Windows Forms app caused severe desktop flicker?
I have a Windows Forms app (.Net 3.5 , C#) with a datagridview in a usercontrol. Occasionally, while running other applications at 开发者_如何学Pythonthe same time (I see it with Louts Notes, but the worst behavior is a user with Reuters Bridge Station) , switching to my app and then to the other app causes the entire desktop to flicker, freezing all user interactions, from a few seconds to close to a minute. (All users using Windows XP Professional) This happens even with a small amount of data in the grid I am not doing any custom painting in the app, and I am pretty certain none of my code is running at this time to call any refreshes or repaints.
I have already enabled double-buffering, so that's not the solution.
One interesting thing I found (in a MS forum) is that setting the TransparencyKey of the form will solve the problem - sometimes. (specifically for the Louts Notes users, but not for the Bridge Station users.) The users still affected are working around it by minimizing the app after data entry, before switching to the other apps. Any ideas will be greatly appreciated, as I am pulling out my hair over this. And I do not have too much hair to start with.
YS
If this happens when debugging from visual studio you could try enabling Framework debugging and Tracepoints to write log entries to the Output window, this technique is quite useful for getting to the bottom of strange Winforms issues.
Once you've located something that's you think is getting called excessively or unnecessarily you can then stick in a breakpoint and look on the stack to see what's causing the problem.
Using the blind squirrel school of troubleshooting, I seem to have found a nut... I mean workaround- I dialed down the display hardware acceleration to the minimum (just above "None"). This, together with setting the TransparencyKey, looks like it fixed my issue.
In the final analysis, while this indicates problems with the display drivers (probably Multi-monitor specific), there is also a .NET problem, as 1) The problem only occurs when my program is run. 2) Updating the drivers on a test machine does not fix the problem.
精彩评论