Skip to main content
A newer version of this page is available. .

AlertControl.BeforeFormShow Event

Fires before displaying an alert window and allows it to be customized.

Namespace: DevExpress.XtraBars.Alerter

Assembly: DevExpress.XtraBars.v19.1.dll

Declaration

[DXCategory("Events")]
public event AlertFormEventHandler BeforeFormShow

Event Data

The BeforeFormShow event's data class is DevExpress.XtraBars.Alerter.AlertFormEventArgs.

Remarks

Handle the BeforeFormShow event to customize an alert window before it’s displayed on-screen. You can access and change the caption, description and other display options of the currently displayed alert window via the event’s e.AlertForm.Info parameter.

Use the following options to change an alert window’s settings:

  • e.AlertForm.Info parameter allows the window’s caption, description and other display options to be modified.
  • e.AlertForm.OpacityLevel parameter allows the window’s opacity level to be changed.

    Alert windows appear on-screen with a fade-in effect, and by default they are semi-transparent at the end of the fade-in. The OpacityLevel parameter specifies the final opacity level of the fade-in effect. A 0 value means the window is transparent. A value of 1 makes the window opaque.

  • e.AlertForm.Size parameter allows the window’s size to be changed.
  • e.Location parameter allows the window’s location to be manually specified. By default, the window’s location is controlled by the AlertControl.FormLocation property.

Example

This example displays an alert window and demonstrates how to respond to clicking the alert window’s content. The shown alert window is made opaque in the BeforeFormShow event handler.

using DevExpress.XtraEditors;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ShowAlertWindow {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }

        private void simpleButton1_Click(object sender, EventArgs e) {
            Message msg = new Message();
            alertControl1.Show(this, msg.Caption, msg.Text, "", msg.Image, msg);
        }

        private void alertControl1_BeforeFormShow(object sender, DevExpress.XtraBars.Alerter.AlertFormEventArgs e) {
            //Make the Alert Window opaque
            e.AlertForm.OpacityLevel = 1;
        }

        private void alertControl1_AlertClick(object sender, DevExpress.XtraBars.Alerter.AlertClickEventArgs e) {
            //Process Alert Window click
            Message msg = e.Info.Tag as Message;
            XtraMessageBox.Show(msg.Text, msg.Caption);
        }
    }

    public class Message {
        public Message() {
            this.Caption = "LILA-Supermercado";
            this.Text = "Carrera 52 con Ave. Bolívar #65-98 Llano Largo";
            this.Image = global::ShowAlertWindow.Properties.Resources.opportunities_32x32;
        }
        public string Caption { get; set; }
        public string Text { get; set; }
        public Image Image { get; set; }
    }
}
See Also