Back to Devexpress

AlertControl.AlertClick Event

windowsforms-devexpress-dot-xtrabars-dot-alerter-dot-alertcontrol-af32b336.md

latest4.3 KB
Original Source

AlertControl.AlertClick Event

Fires when the text of alert windows is clicked.

Namespace : DevExpress.XtraBars.Alerter

Assembly : DevExpress.XtraBars.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
[DXCategory("Events")]
public event AlertClickEventHandler AlertClick
vb
<DXCategory("Events")>
Public Event AlertClick As AlertClickEventHandler

Event Data

The AlertClick event's data class is AlertClickEventArgs. The following properties provide information specific to this event:

PropertyDescription
ActivateOwnerGets or sets whether the owner (a form) of the current alert window is activated after executing your AlertControl.AlertClick event handler.
AlertFormGets the currently processed alert window.
InfoGets an object that contains information displayed in the currently processed alert window.

Remarks

You can handle this event to respond to clicking the text in alert windows. For instance, you can move focus to another window, focus another control, etc.

If the AlertControl.AllowHotTrack option is disabled, the AlertClick event will not be raised when clicking an alert window’s text.

Example

The following example shows how you can respond to an end-user clicking an alert window’s text. To respond to these actions, the AlertControl.AlertClick event is handled.

In the example, it’s assumed that alert windows are used to show notifications to end-users when a new e-mail arrives. When a new alert window is created, a custom MailData object is associated with the window. This object contains information on the e-mail received, and it is accessed and processed while handling the AlertControl.AlertClick event.

csharp
private void ShowAlertWindow() {
    Form owner;
    string caption, text, hotTrackedText;
    Image image;
    MailData mailData;
    // Initialize the owner, caption, text, hotTrackedText, image and mailData
    // ...
    // Show an alert window with these parameters
    alertControl1.Show(owner, caption, text, hotTrackedText, image, mailData);
}

private void alertControl1_AlertClick(object sender, AlertClickEventArgs e) {
    // Get and process the data associated with the current alert window.
    MailData mailData = e.Info.Tag as MailData;
    ShowEmail(mailData);
}

private void ShowEmail(MailData mailData) {
    //...
}

public class MailData {
    //...
}
vb
Private Sub ShowAlertWindow()
    Dim owner As Form
    Dim caption, text, hotTrackedText As String
    Dim image As Image
    Dim mailData As MailData
    ' Initialize the owner, caption, text, hotTrackedText, image and mailData
    ' ...
    ' Show an alert window with these parameters
    alertControl1.Show(owner, caption, text, hotTrackedText, image, mailData)
End Sub

Private Sub AlertControl1_AlertClick(ByVal sender As System.Object, _
ByVal e As AlertClickEventArgs) Handles AlertControl1.AlertClick
    ' Get and process the data associated with the current alert window.
    Dim mailData As MailData = TryCast(e.Info.Tag, MailData)
    ShowEmail(mailData)
End Sub

Private Sub ShowEmail(ByVal mailData As MailData)
    '...
End Sub

Public Class MailData
    '...
End Class

See Also

AllowHotTrack

AlertControl Class

AlertControl Members

DevExpress.XtraBars.Alerter Namespace