C# Programming > Windows Forms

C# Vista Style Task-Dialog

vista task dialog

Vista Controls

Windows Vista introduced an amazing new look to user interface. Along with other user controls, the new TaskDialog improves upon traditional confirmation boxes. Instead of prompting a user with a simple Yes-No MessageBox, the Task-Dialog introduces a more visual approach to ask a user a question. A TaskDialog is faster and easier for a user than a traditional C# MessageBox.

There are ways to use Vista libraries to prompt the built-in TaskDialog. However, if we want our Vista-style TaskDialog to work on older versions of Windows, we have to draw the controls ourselves.

Thus we'll be using Visual C# Kicks Command Link control (the professional CommandLink also works), and putting it together with a Form to create a Vista-style TaskDialog with pure C#


You want the Vista TaskDialog to remain dynamic. Thus the Form size should change depending on the amount of text being displayed. Luckily a lot of the work is already done for you. By displaying the display string in a Label, you can check to see whether the new Label's size overlaps other controls or goes outside the Form bounds.

The Form can then be resized appropriately. Additionally by setting the Anchor property of the buttons to Bottom-Left, you don't have to manually reposition the Yes-No Command-Links.

Vista Icons

To avoid having to redraw Vista icons, you can use the SystemIcons class provided by the .Net Framework. The additionally benefit is that the icons will match those of traditional a MessageBox, keeping the overall look of the application consistent with the operating system.

Download the provided C# source code to test how the Vista-style TaskDialog looks on your system. Notice the CommandLink control is written entirely in C# and can be easily added to any .NET application. Feel free to use it in your existing and future projects...

Back to C# Article List