SftTaskDialog shows a task dialog: a heading, a text, an icon, buttons and command links, and optionally radio buttons, a verification check box, an expander, a footnote and a progress bar (see Task Dialog Elements). SftTaskDialog has the classes and members of the Windows Forms TaskDialog and works the same way. The dialog is drawn by SftStyle/NET, so it is available on the .NET Framework, which has no task dialog of its own, and on .NET 10 (or later), and it takes the mode of the application's SftStyle component when it opens: light, dark or with the colors of the Windows contrast theme.

The contents of the dialog are an SftTaskDialogPage object. SftTaskDialog.ShowDialog shows the page and returns the button that closed the dialog:
C#
SftTaskDialogPage page = new SftTaskDialogPage { Caption = "Orders", Heading = "The order has not been shipped yet", Text = "Order 10482 for Avery Johnson is packed but has no tracking number.", Icon = SftTaskDialogIcon.Warning, }; SftTaskDialogCommandLinkButton ship = new SftTaskDialogCommandLinkButton("&Ship now", "Prints the label and notifies the customer."); SftTaskDialogCommandLinkButton hold = new SftTaskDialogCommandLinkButton("&Hold the order", "Keeps it in the packing area until tomorrow."); page.Buttons.Add(ship); page.Buttons.Add(hold); page.Buttons.Add(SftTaskDialogButton.Cancel); SftTaskDialogButton result = SftTaskDialog.ShowDialog(this, page); if (result == ship) ShipOrder();
VB
Dim page As New SftTaskDialogPage With { .Caption = "Orders", .Heading = "The order has not been shipped yet", .Text = "Order 10482 for Avery Johnson is packed but has no tracking number.", .Icon = SftTaskDialogIcon.Warning } Dim ship As New SftTaskDialogCommandLinkButton("&Ship now", "Prints the label and notifies the customer.") Dim hold As New SftTaskDialogCommandLinkButton("&Hold the order", "Keeps it in the packing area until tomorrow.") page.Buttons.Add(ship) page.Buttons.Add(hold) page.Buttons.Add(SftTaskDialogButton.Cancel) Dim result As SftTaskDialogButton = SftTaskDialog.ShowDialog(Me, page) If result = ship Then ShipOrder()
| Member | Description |
|---|---|
| SftTaskDialogPage.Caption | The text of the title bar. |
| SftTaskDialogPage.Heading | The main instruction, in a larger font above the text. |
| SftTaskDialogPage.Text | The text of the dialog. |
| SftTaskDialogPage.Icon | The icon beside the heading: SftTaskDialogIcon.Information, SftTaskDialogIcon.Warning, SftTaskDialogIcon.Error, SftTaskDialogIcon.Shield, a shield icon that puts the heading on a colored bar (SftTaskDialogIcon.ShieldBlueBar, SftTaskDialogIcon.ShieldGrayBar, SftTaskDialogIcon.ShieldWarningYellowBar, SftTaskDialogIcon.ShieldErrorRedBar, SftTaskDialogIcon.ShieldSuccessGreenBar), or an icon of the application's own, made from an Icon, a Bitmap or an icon handle. |
| SftTaskDialogPage.Buttons | The buttons and command links. Without buttons the page shows an OK button. |
| SftTaskDialogPage.DefaultButton | The button that has the focus and is clicked with Enter when the page appears; without it, the first enabled button. |
| SftTaskDialogPage.AllowCancel | Lets Esc and the close box close a dialog that has no Cancel button; the result is then a Cancel button the dialog creates, equal to SftTaskDialogButton.Cancel. A page without a Cancel button and without AllowCancel has no close box, and Esc does nothing. |
| SftTaskDialogPage.AllowMinimize | Gives the dialog a minimize box. |
| SftTaskDialogPage.SizeToContent | Widens the dialog beyond its standard width as far as the heading and the text need, up to two thirds of the screen. |
| SftTaskDialogPage.RightToLeftLayout | Lays the dialog out from right to left. |
SftTaskDialog.ShowDialog shows the dialog in front of the owner passed to it, centered on the owner or, with SftTaskDialogStartupLocation.CenterScreen, on the screen. Without an owner the dialog is centered on the screen and has a taskbar button, and the other windows of the application stay enabled, as with the Windows Forms TaskDialog. SftTaskDialog.ShowDialogAsync shows the dialog once the current event handler has returned and returns a task that completes with the button that closed it.
ShowDialog throws an InvalidOperationException when the page cannot be shown: when it is already shown, when one of its elements belongs to a page that is shown, when more than one of its radio buttons is checked, when a custom button or a radio button has no text, and when SftTaskDialogPage.DefaultButton is not one of its buttons.
While the page is shown, these properties can be changed and the dialog follows at once: the page's SftTaskDialogPage.Caption, SftTaskDialogPage.Heading, SftTaskDialogPage.Text and SftTaskDialogPage.Icon, a button's SftTaskDialogButton.Enabled and SftTaskDialogButton.ShowShieldIcon, a radio button's SftTaskDialogRadioButton.Enabled and SftTaskDialogRadioButton.Checked, the verification check box's SftTaskDialogVerificationCheckBox.Checked, the expander's SftTaskDialogExpander.Text, the footnote's SftTaskDialogFootnote.Text and SftTaskDialogFootnote.Icon, and the progress bar's state and values. The other properties of the page and its elements throw an InvalidOperationException then, as do changes of the SftTaskDialogPage.Buttons and SftTaskDialogPage.RadioButtons collections; to show other contents, navigate to another page (see Task Dialog Navigation).
SftTaskDialogPage.BoundDialog returns the SftTaskDialog that shows the page, and the BoundPage property of each element returns its page. SftTaskDialog.Close closes the dialog with the Cancel result, for example when the work behind a progress bar has finished; the result is the page's Cancel button if it has one, but its Click event does not occur. SftTaskDialogButton.PerformClick clicks a button as the user would, and SftTaskDialog.Handle returns the window handle of the dialog.
The static properties of SftTaskDialogButton return new instances of the standard buttons: OK, Cancel, Abort, Retry, Ignore, Yes, No, Close, Help, TryAgain and Continue, whose text comes in the language of Windows. A standard button is equal to any other instance of the same standard button, with == as with Equals, so the result can be compared with SftTaskDialogButton.Cancel; a page can have each standard button once. A custom button is created with its text; an ampersand marks its mnemonic. The custom buttons appear in the order of the SftTaskDialogPage.Buttons collection, followed by the standard buttons in the order of the Windows task dialog: OK, Yes, No, Abort, Retry, Cancel, Ignore, Try Again, Continue, Close and Help.
SftTaskDialogCommandLinkButton is a command link: a large button in the content area with an arrow, a text and a description below it (SftTaskDialogCommandLinkButton.DescriptionText). The other buttons appear at the bottom right.
| Member | Description |
|---|---|
| SftTaskDialogButton.Text | The text of a custom button. A standard button has the text Windows gives it, which cannot be changed. |
| SftTaskDialogButton.Enabled, SftTaskDialogButton.Visible | Whether the button can be clicked and whether it is shown. |
| SftTaskDialogButton.ShowShieldIcon | Shows the shield icon on the button or, on a command link, instead of the arrow, to tell the user that the action needs elevated rights. |
| SftTaskDialogButton.Click | Occurs when the button is clicked. |
| SftTaskDialogButton.AllowCloseDialog | Whether clicking the button closes the dialog (True by default). With False the dialog stays open and the button's Click event does the work, for example applying a setting. |
| SftTaskDialogButton.PerformClick | Clicks the button while its page is shown. |
Esc and the close box click the page's Cancel button, so its Click event occurs and its SftTaskDialogButton.AllowCloseDialog applies. The Help button never closes the dialog: it raises the SftTaskDialogPage.HelpRequest event, as F1 does. A Click handler that navigates to another page keeps the dialog open as well (see Task Dialog Navigation).