Skip to content

TaskDialog

Public Class

A task dialog is a dialog box that can be used to display information and receive simple input from the user. It has a common set of controls that are arranged in a standard order to assure consistent look and feel.

Inheritance Hierarchy

System.Object
Autodesk.Revit.DB.APIObject
Autodesk.Revit.UI.TaskDialog

Namespace: Autodesk.Revit.UI

Assembly: RevitAPIUI (in RevitAPIUI.dll) Version: 25.0.0.0 (25.0.0.0)

Syntax

public class TaskDialog : APIObject

The TaskDialog type exposes the following members.

Constructors

Name

Description


Public Method
TaskDialog

Creates a task dialog with title.


Properties

Name

Description


Public Property
AllowCancellation

Whether the task dialog can be cancelled if no cancel button is specified.


Public Property
CommonButtons

The push buttons displayed in the task dialog.


Public Property
DefaultButton

The default button for the dialog.


Public Property
EnableMarqueeProgressBar

Enables a marquee style progress bar to be displayed in the TaskDialog.


Public Property
ExpandedContent

ExpandedContent is hidden by default and will display at the bottom of the task dialog when the “Show details” button is pressed.


Public Property
ExtraCheckBoxText

ExtraCheckBoxText is used to label the extra checkbox.


Public Property
FooterText

FooterText is used in the footer area of the task dialog.


Public Property
Id

The Id of the task dialog.


Public Property
Code Example

Identifies if the object is read-only or modifiable.
(Inherited from APIObject)


Public Property
MainContent

MainContent is the smaller text that appears just below the main instructions.


Public Property
MainIcon

The icon shown in the task dialog.


Public Property
MainInstruction

The large primary text that appears at the top of a task dialog.


Public Property
Title

Title of the task dialog.


Public Property
TitleAutoPrefix

Whether the TaskDialog’s title will automatically have the add-in name added as a prefix.


Public Property
VerificationText

VerificationText is used to label the verification checkbox.


Methods

Name

Description


Public Method
AddCommandLink(TaskDialogCommandLinkId, String)

Adds a CommandLink associated to the given id, displaying the indicating main content.


Public Method
AddCommandLink(TaskDialogCommandLinkId, String, String)

Adds a CommandLink associated to the given id, displaying the indicating main and supporting content.


Public Method
Dispose

Causes the object to release immediately any resources it may be utilizing.
(Inherited from APIObject)


Public Method
EnableDoNotShowAgain

Enables the “Do not show again” for a task dialog.


Public Method

Equals

Determines whether the specified object is equal to the current object.
(Inherited from Object)


Public Method

GetHashCode

Serves as the default hash function.
(Inherited from Object)


Public Method

GetType

Gets the Type of the current instance.
(Inherited from Object)


Public Method

Shows the task dialog.


Public Method
Static Member

Shows a task dialog with title, main instruction and a Close button.


Public Method
Static Member

Shows a task dialog with title, main instruction and common buttons.


Public Method
Static Member

Shows a task dialog with title, main instruction, common buttons and default buttons.


Public Method

ToString

Returns a string that represents the current object.
(Inherited from Object)


Public Method

Gets the status of the extra checkbox.


Public Method

Gets the status of the verification checkbox.


Remarks

There are two ways to create and show a task dialog to the user. The first option is to construct the TaskDialog, set its properties individually, and use the instance method Show() to show it to the user. The second is to use one of the static Show() methods to construct and show the dialog in one step. When you use the static methods only a subset of the options can be specified.

Please follow Revit standards to create task dialogs. The standards are listed in the remarks of each property or method.

Example

// Get the application and document from external command data.
Application app = commandData.Application.Application;
Document activeDoc = commandData.Application.ActiveUIDocument.Document;
// Creates a Revit task dialog to communicate information to the user.
TaskDialog mainDialog = new TaskDialog("Hello, Revit!");
mainDialog.MainInstruction = "Hello, Revit!";
mainDialog.MainContent =
"This sample shows how to use a Revit task dialog to communicate with the user."
+ "The command links below open additional task dialogs with more information.";
// Add commmandLink options to task dialog
mainDialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink1,
"View information about the Revit installation");
mainDialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink2,
"View information about the active document");
// Set common buttons and default button. If no CommonButton or CommandLink is added,
// task dialog will show a Close button by default
mainDialog.CommonButtons = TaskDialogCommonButtons.Close;
mainDialog.DefaultButton = TaskDialogResult.Close;
// Set footer text. Footer text is usually used to link to the help document.
mainDialog.FooterText =
"<a href=\"http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=2484975 \">"
+ "Click here for the Revit API Developer Center</a>";
TaskDialogResult tResult = mainDialog.Show();
// If the user clicks the first command link, a simple Task Dialog
// with only a Close button shows information about the Revit installation.
if (TaskDialogResult.CommandLink1 == tResult)
{
TaskDialog dialog_CommandLink1 = new TaskDialog("Revit Build Information");
dialog_CommandLink1.MainInstruction =
"Revit Version Name is: " + app.VersionName + "\n"
+ "Revit Version Number is: " + app.VersionNumber + "\n"
+ "Revit Version Build is: " + app.VersionBuild;
dialog_CommandLink1.Show();
}
// If the user clicks the second command link, a simple Task Dialog
// created by static method shows information about the active document
else if (TaskDialogResult.CommandLink2 == tResult)
{
TaskDialog.Show("Active Document Inforamtion",
"Active document: " + activeDoc.Title + "\n"
+ "Active view name: " + activeDoc.ActiveView.Name);
}
return Autodesk.Revit.UI.Result.Succeeded;