[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Collapse]eXpressApp Framework
 [Expand]Getting Started
 [Expand]Design-Time Features
 [Collapse]Task-Based Help
  [Expand]Business Model Design
  [Expand]Application Model
  [Expand]List Editors
  [Expand]Property Editors
  [Expand]Scheduler and Notifications
  [Expand]Maps Module
  [Collapse]Miscellaneous UI Customizations
    How to: Add a Button to a Detail View Using a Custom View Item
    How to: Add an XAF Mobile Custom Module
    How to: Adjust the Size and Style of Pop-up Dialogs (ASP.NET)
    How to: Adjust the Windows' Size and Style
    How to: Change an Application Logo and Info
    How to: Create a Custom Control Detail Item
    How to: Customize a Window Caption
    How to: Customize ASP.NET Layout Elements Using Custom CSS Classes
    How to: Customize Export Options of the Printing System
    How to: Customize the Conditional Appearance Module Behavior
    How to: Customize Window Status Messages (WinForms)
    How to: Enable High DPI Support in a WinForms Application
    How to: Implement a Custom Messaging Class
    How to: Implement Client-Side Logic in Mobile Applications
    How to: Include an Action to a Detail View Layout
    How to: Raise XAF Callbacks from Client-Side Events and Process these Callbacks on Server
    How to: Set Images and Captions for Enumeration Values
    How to: Show a Custom Window with an Embedded XAF View
    How to: Show a Custom Windows Form
    How to: Use a Custom Plugin in a Mobile Application
    How to: Use a DevExtreme Chart in a Mobile Application
    How to: Use Custom Themes in ASP.NET Applications
  Frequently Asked Questions (FAQ)
 [Expand]API Reference
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

How to: Implement a Custom Messaging Class

Message boxes that contain text and several buttons are be displayed in Windows Forms XAF applications in many situations. For instance, a message box is shown when an end-user closes a Detail View with modified data or cancels changes via the ModificationsController.CancelAction Action. These message boxes are provided by the Messaging class.

This class utilizes the XtraMessageBox functionality. In certain scenarios it can be required to customize the Messaging class. In this instance you should inherit this class. This topic details a way of implementing such a descendant.


A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E1527.


You can handle the Messaging.ConfirmationDialogClosed event instead of implementing a custom Messaging class, if executing a custom code after upon the closing of a message box is required.

Expanded Change the Default Focused Button

The Messaging class exposes the Messaging.Show virtual method, which displays a message box via the XtraMessageBox.Show method. The XtraMessageBox.Show overload that takes owner, text, caption, buttons and icon parameters is used by default. This overload displays a message box with the first ("OK") button initially focused. In this example, we will override the Messaging.Show method and use another XtraMessageBox.Show method's overload that takes the defaultButton extra parameter. Thus, it will be possible to specify which button to focus.

Add a new CustomXtraMessageBoxMessaging class to your Windows Forms module project. This class should inherit the Messaging class. Add the default public constructor and override the ShowCore method as it is shown in the snippet below.

Invoke the Model Editor for the Windows forms module project and navigate to the Options node. The IModelOptionsWin.Messaging property specifies the type of messaging used in Windows Forms application. Set this property value to the fully qualified name of your custom class (e.g. "CustomMessaging.Module.Win.CustomXtraMessageBoxMessaging").

Run the Windows Forms application. Open any persistent object's Detail View and make some changes. Click Close. The message box with "No" button focused will be displayed.

Expanded Use a custom Message Box instead of XtraMessageBox

You can use a fully custom message box in your Messaging implementation. In the snippet below, a use of System.Windows.Forms.MessageBox class is demonstrated.

Invoke the Model Editor for the Windows forms module project. Navigate to the Options node. Set the IModelOptionsWin.Messaging property to the fully qualified name of your custom class (e.g. "CustomMessaging.Module.Win.CustomWinFormsMessageBoxMessaging").

Run the Windows Forms application. Open any persistent object's Detail View and make some changes. Click Close. The following message box will be displayed.

Expanded See Also

Is this topic helpful?​​​​​​​