Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News New Features for Windows Forms 5.0

New Features for Windows Forms 5.0

This item in japanese


For the first time since .NET 2.0, Windows Forms, a.k.a. WinForms, has received new features that are not High DPI-related.

Windows Forms, a.k.a. WinForms, has had only two major releases: .NET 1 and .NET 2.0. Since then, there have been the occasional bug fix or High DPI enhancement, but all feature development had effectively stopped. Yet the technology, which is often thought of as a thin wrapper around the native Windows UI, was never officially deprecated. And new projects continued to be developed in it, especially internal business applications where its simplicity and performance were valued.

For .NET 5.0, development in new Windows Forms features began in earnest. Much of this was community sponsored, with over 70% of its 900 pull-requests coming from outside Microsoft.

Task Dialog - New

The Task Dialog was introduced in Windows Vista as a replacement for the Message Box dialog that Windows has used since the 90’s. Unlike the Message Box, which only allowed pre-determined pairs of options such as Ok/Cancel or Yes/No, developers can supply their own text for options in a Task Dialog. Other features include:

  • Separate “main instruction”, “content”, “additional information”, and “footer” text blocks
  • Radio buttons
  • A checkbox with label, usually used for “Do not ask me again”
  • Progress bar with optional timer and auto-close
  • Separate main and footer icons
  • The option to minimize

Though part of the operating system, the Task Dialog was not exposed in WinForms by Microsoft. However, it could still be used via Win32 library calls (i.e., p/invoke). In a 2007 Code Project article titled TaskDialog for WinForms, KevinGre demonstrates how this can be done.

Konstantin Preißer of CoDaBix provided the .NET 5 implementation. The documentation for his version of the TaskDialog can be found on Microsoft Docs, though his GitHub repository may be more informative.

List View Control - Enhancement

The basic capabilities of the List View control should be well known by Windows Forms developers. But what most probably didn’t know is the control was greatly enhanced in Windows Vista. As mentioned above, development on Windows Forms had ceased in 2005 so these enhancements were never carried over. These include:

As with the Task Dialog, this functionality could potentially be accessed via Win32 calls if you knew they existed.

Fortunately, Hugh Bellamy and Loni Tra were aware of them and provided the necessary wrappers for .NET 5.0.

File Dialog - Enhancement

Our final example of exposing Win32 features involves the File Dialog.

FileDialog has received a new API: FileDialog.ClientGuid. The Windows file dialog enables a calling application to associate a GUID with a dialog’s persisted state. A dialog’s state can include factors such as the last visited folder and the position and size of the dialog. Typically, this state is persisted based on the name of the executable file. By specifying a GUID, an application can have different persisted states for different versions of the dialog within the same application (for example, an import dialog and an open dialog).

Joseph Musser of the NUnit Core Team contributed this feature.

Accessibility Improvements

Modernizing the accessibility features of Windows Forms has also been a high priority. This includes UI Automation support various controls, LegacyIAccessible Control Pattern support, and Text and TextRange Control Patterns support. More information on accessibility can be found on the .NET developer blog.

Work has begun on Windows forms for .NET 6.0. You can see what’s planned in the 6.0 Preview1 and 6.0 milestones. (And yes, more High DPI enhancements are coming.)

Rate this Article


Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

  • well exlained

    by kaustubh nv,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Nice article

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p