Many of my personal projects such as DiskDigger, DiskImager, and so on are written using Windows Forms, on top of the Microsoft .NET framework. This is because these projects of mine were originally created many years ago during the heyday of Windows Forms, and I made somewhat of a gamble that WinForms would be a sustainable choice in the long term.
Fast forward to today, and it seems like mentioning Windows Forms in polite company evokes a chuckle or two. WinForms is now considered by many to be a quaint relic of a bygone era, which has been largely superseded by new and superior frameworks.
That being said, my old personal projects are still used by a good number of people, and even though Iâ€™ve added plenty of new features over the years, I havenâ€™t changed a thing about the fact that they still use WinForms. And even when I need to create a new GUI app for some random purpose today, I find myself reaching for a blank WinForms project.
So why do I still use WinForms in my personal projects, and why have I not abandoned it in favor of something newer like UWP, or something more cross-platform like Qt?
Because it bloody works. You might have noticed that support for Windows Forms in the most recent versions of .NET is as robust as ever, and in no danger of being dropped. This is because WinForms is an extremely solid foundation for building GUI apps. All of the components are intuitive, make sense, and feel native to the platform, because they are. If you donâ€™t need any of the fanciness provided by XAML such as animating components at every opportunity, rotating buttons by 12 degrees, or making your app run on Xbox One, then WinForms is for you!
Because itâ€™s an absolute pleasure to use. Creating a new Windows Forms project in Visual Studio takes four clicks at the most, and youâ€™re up and running. Designing your appâ€™s window is as simple as dragging and dropping components from a toolbox and adjusting their properties to your liking. Creating an event handler for a component is as simple as double-clicking it. Thereâ€™s virtually no boilerplate code to worry about — just focus on the code that responds to a button click, ListView selection, etc.
Because itâ€™s compatible and lean. Compatible in the sense of running across various versions of Windows, that is. If you target the right version of the .NET framework, your WinForms app will run perfectly well on Windows XP as well as the latest build of Windows 10. As for leanness, a â€œhello worldâ€ graphical app is on the order of a few kilobytes, and even a hugely complex app would be hard-pressed to exceed a few megabytes of bytecode.
Compatibility (or lack thereof) with other operating systems is, of course, the major unfortunate drawback. This is where my original gamble from years ago didnâ€™t pay off as much.Â Since .NET was touted as a â€œcross-platformâ€ framework, I thought naively that components like WinForms would eventually be ported over to Linux and macOS in an official way by Microsoft. This never happened, and the only real â€œportingâ€ was done by the excellent Mono project, whose port of WinForms is great but not perfect, and really only works in Linux and not macOS.
Nevertheless, despite the blemish of the lack of actual cross-platform support, WinForms remains a truly solid choice for desktop GUI development on Windows. Donâ€™t be surprised if we keep seeing WinForms used by hobbyists and enterprises well into the future, and donâ€™t hesitate to give WinForms a second look yourself. It might not be the shiniest new thing, but it has persisted this long for a reason.