开发者

How can you speed up the display of WinForms in C#? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 12 years ago.

How can you speed up the display of WinForms in C#?

I am finding that forms are being painted quite slowly, even if the window is being 'reac开发者_开发百科tivated' (ie. switched to) after having been already loaded.

Other languages seem to be render forms a lot quicker.

Is there a way to speed things up? Using C# in VS2005.


From reading some of your comments it looks like you're not hammering the UI thread by overriding Paint(), nor drawing large bitmaps. Im assuming then that you have lots and lots of forms controls. I've definitely killed my UI responsiveness by having lots of these controls and the form seems to update in waves, and to be honest I've not found a good solution short of reducing the number of forms or switching UI libraries.

I'm going to throw my $0.02USD and suggest you take a look at WPF. I have forms with several dozen custom controls that each contain 10 or so more controls, and the UI simply flies. If you're at all able to transition over to WPF, you will be glad you did. Lots of great help on these forums every step of the way :D


try to load the data in background using the backgroundworker.

At the end you can achieve a seemslikefastscreen using splash screens and loading data presenting the screen disabled or a wait icon until you recover them.


Well if fast drawing is a super important requirement, I would suggest using DirectX instead of GDI+. DirectX is MUCH fast because it utilizes the CPU in your graphics card.

If, however, you want to stick with GDI+, then you can get a pretty good speed performance by doing all your drawing in a bitmap then transfering that bitmap to the screen. To do this, first create a new Bitmap object, the same size as your client area. Next, use Graphics.FromImage(yourbitmap) to get a graphics handle to your bitmap. Next, do your drawing like you normally would, using the graphics handle you got from your bitmap. Finally, use DrawImage() to transfer your bitmap to your form.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜