Now that we’ve published the beta for v17.2, it’s time to reveal a major new enhancement for our WinForms grid. After reading this, I’m going to bet you’ll be downloading the installer and trying it out for yourself. Let us know your results!
WinForms. It’s been around since the very first days of .NET. Our first control for the run-time, released before .NET had even come out of beta (2002!), was XtraGrid, and we’ve released numerous other controls and suites for the platform since then. And after 15 years, Microsoft has pretty much frozen new development for WinForms. It’s got that taint of “legacy”.
And yet… People are still writing new thick-client apps for Windows. They have existing successful business apps in daily use that need maintaining and enhancing. Indeed, in every major release we provide new functionality and even new controls for WinForms. It is not going away.
One big issue is that, compared to 15 years ago, the monitors and display adapters we use for Windows have become faster and have much higher resolution and WinForms has not kept up. We are now talking about and using 4K screens, so called because they are roughly 4,000 pixels horizontally (the main standard is 3840×2160, which is twice the resolution horizontally and vertically of the 1080p standard, or 4 times the number of pixels). Not only that, but the standard for drawing graphics on the screen has changed: it used to be GDI+ but is now DirectX. One of the big differences between the two is DirectX renders graphics through hardware acceleration, whereas the older GDI+ does not; simply put, DirectX is faster. Poor old WinForms still uses GDI+ under the hood.
Given all this, our WinForms team at DevExpress decided to do an experiment, or a spike in development-speak: could they take one of our more complicated WinForms controls—oh, let’s say that original control we wrote, the good old data grid – and change its rendering code to use DirectX and hardware acceleration instead of the “built-in” WinForms GDI+? Would anyone notice the purported speed improvements?
[…time passes, lots of work is done…]
Well? The result? Wow. To be blunt: this is going to revolutionize WinForms.
A big example: one of the most intensive rendering tasks we can do with the data grid is to scroll the rows in the grid pixel-by-pixel. On one of our hi-res test machines, with GDI+ we get about 22 frames per second. In other words, what’s happening in crude terms is for each frame the code is scrolling the data rows by a pixel and then adding another single row of pixels. Every second on the test machine, we can do that 22 times with GDI+. Just about flicker free. With DirectX? 72 FPS, over three times faster. That’s just butter smooth. Our competition, for the same task, is way behind (which also goes to show how well we’d optimized the grid up to now).
With a scroll by page example (where each frame is a new page), we used to get 25 FPS. With DirectX, 35 FPS.
But that’s not all. In essence, all of this work is done way down in the depths of the grid. The DirectX grid is totally compatible with the old GDI+ grid: all that needs to be done is to set a single option. So, you already have an app with our grid but want that extra rendering speed? Recompile with v17.2, set the option, and you’re away. Get on your users’ Christmas card lists again.
There are some limitations that you should be aware of with this new functionality. The biggest one is that it does not work under Windows versions that are older than 8, with Windows 7 being the biggest example. I’d have to say that, given that the end of extended support for Windows 7 is only 2 years away, is not that big of an issue. For these older operating system versions, if you set the DirectX hardware-acceleration option, it’s simply ignored and you automatically just get standard GDI+ speeds. (Ditto, if there’s some issue with DirectX rendering, there’s an auto-fallback to GDI+).
Next, if you are doing any of your own drawing in the grid by using the window handle for example, it’ll be ignored, but then again it’s bad practice. If, however, you do have some custom draw handlers that use e.Graphics
, you must now use the e.Cache.*
methods instead. We plan to introduce some special tools and/or modes to catch potential problems with custom draw later.
In v17.2, the only control that will have this enhanced DirectX support will be the aforementioned data grid, XtraGrid. We have plans to upgrade our other major controls in future versions (v18.1, v18.2, and so on). Note that we have our ideas on the order to enhance them (tree list, pivot grid, and so on), but we’d love to hear from you what would be most important to you in your WinForms apps.